<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="./js/coder_app.js"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="./rtwreport_utils.js"></script>
<script type="text/javascript" src="./rtwannotate.js"></script>
<link rel="stylesheet" type="text/css" href="./css/coder_app.css"/>
</head>
<body onload="srcFileOnload();">
<pre id="code">
<table class="code" id="codeTbl">
<tr name="1" id="1">
<td><a id="l1" class='ln'>1</a></td><td><span class="ct">/*</span></td></tr>
<tr name="2" id="2">
<td><a id="l2" class='ln'>2</a></td><td><span class="ct"> * Code generated for Simulink model VCUComposition_demo.</span></td></tr>
<tr name="3" id="3">
<td><a id="l3" class='ln'>3</a></td><td><span class="ct"> *</span></td></tr>
<tr name="4" id="4">
<td><a id="l4" class='ln'>4</a></td><td><span class="ct"> * FILE    : lin.c</span></td></tr>
<tr name="5" id="5">
<td><a id="l5" class='ln'>5</a></td><td><span class="ct"> *</span></td></tr>
<tr name="6" id="6">
<td><a id="l6" class='ln'>6</a></td><td><span class="ct"> * VERSION : 1.86</span></td></tr>
<tr name="7" id="7">
<td><a id="l7" class='ln'>7</a></td><td><span class="ct"> *</span></td></tr>
<tr name="8" id="8">
<td><a id="l8" class='ln'>8</a></td><td><span class="ct"> * DATE    : Sun Sep  8 01:03:14 2024</span></td></tr>
<tr name="9" id="9">
<td><a id="l9" class='ln'>9</a></td><td><span class="ct"> *</span></td></tr>
<tr name="10" id="10">
<td><a id="l10" class='ln'>10</a></td><td><span class="ct"> * Copyright 2011-2017 ECUCoder. All Rights Reserved.</span></td></tr>
<tr name="11" id="11">
<td><a id="l11" class='ln'>11</a></td><td><span class="ct"> */</span></td></tr>
<tr name="12" id="12">
<td><a id="l12" class='ln'>12</a></td><td></td></tr>
<tr name="13" id="13">
<td><a id="l13" class='ln'>13</a></td><td><span class="pp">#include "lin.h"</span></td></tr>
<tr name="14" id="14">
<td><a id="l14" class='ln'>14</a></td><td><span class="pp">#if</span> 1</td></tr>
<tr name="15" id="15">
<td><a id="l15" class='ln'>15</a></td><td><span class="pp">#define</span> <a id="15c9" class="tk">LIN0_COMBTX_DMACH</a>              0</td></tr>
<tr name="16" id="16">
<td><a id="l16" class='ln'>16</a></td><td><span class="pp">#define</span> <a id="16c9" class="tk">LIN0_COMBRX_DMACH</a>              1</td></tr>
<tr name="17" id="17">
<td><a id="l17" class='ln'>17</a></td><td></td></tr>
<tr name="18" id="18">
<td><a id="l18" class='ln'>18</a></td><td><span class="kw">static</span> <a id="18c8" class="tk">uint8_t</a> <a id="18c16" class="tk">ec_lin0_txlock</a> = 0;</td></tr>
<tr name="19" id="19">
<td><a id="l19" class='ln'>19</a></td><td><a id="19c1" class="tk">LIN_INFO_tag</a> <a id="19c14" class="tk">ec_lin_dma_info</a>;</td></tr>
<tr name="20" id="20">
<td><a id="l20" class='ln'>20</a></td><td></td></tr>
<tr name="21" id="21">
<td><a id="l21" class='ln'>21</a></td><td><span class="pp">#define</span> <a id="21c9" class="tk">LIN0_RXDMA_EN</a>                  1</td></tr>
<tr name="22" id="22">
<td><a id="l22" class='ln'>22</a></td><td><span class="pp">#define</span> <a id="22c9" class="tk">LIN0_COMBRX_DMACH</a>              1</td></tr>
<tr name="23" id="23">
<td><a id="l23" class='ln'>23</a></td><td></td></tr>
<tr name="24" id="24">
<td><a id="l24" class='ln'>24</a></td><td><a id="24c1" class="tk">uint8_t</a> <a id="24c9" class="tk">LIN0_RXMSG_ACTIVE</a> = 0;</td></tr>
<tr name="25" id="25">
<td><a id="l25" class='ln'>25</a></td><td><span class="kw">static</span> <a id="25c8" class="tk">uint8_t</a> <a id="25c16" class="tk">ec_lin0_rxlock</a> = 0;</td></tr>
<tr name="26" id="26">
<td><a id="l26" class='ln'>26</a></td><td><span class="kw">static</span> <a id="26c8" class="tk">uint8_t</a> <a id="26c16" class="tk">ec_lin0_rxdata</a>[64];</td></tr>
<tr name="27" id="27">
<td><a id="l27" class='ln'>27</a></td><td><a id="27c1" class="tk">uint8_t</a> <a id="27c9" class="tk">ec_lin0_dstdata</a>[64];</td></tr>
<tr name="28" id="28">
<td><a id="l28" class='ln'>28</a></td><td></td></tr>
<tr name="29" id="29">
<td><a id="l29" class='ln'>29</a></td><td><span class="ct">// LINA</span></td></tr>
<tr name="30" id="30">
<td><a id="l30" class='ln'>30</a></td><td><span class="pp">#define</span> <a id="30c9" class="tk">LIN0_TXMSG_SIZE</a>                64</td></tr>
<tr name="31" id="31">
<td><a id="l31" class='ln'>31</a></td><td></td></tr>
<tr name="32" id="32">
<td><a id="l32" class='ln'>32</a></td><td><a id="32c1" class="tk">uint8_t</a> <a id="32c9" class="tk">LIN0_TXMSG_SRCIDX</a> = 0;</td></tr>
<tr name="33" id="33">
<td><a id="l33" class='ln'>33</a></td><td><a id="33c1" class="tk">uint8_t</a> <a id="33c9" class="tk">LIN0_TXMSG_DSTIDX</a> = 0;</td></tr>
<tr name="34" id="34">
<td><a id="l34" class='ln'>34</a></td><td><a id="34c1" class="tk">LIN_TXMSG_T</a> <a id="34c13" class="tk">LIN0_TXMSG_BUF</a>[<a id="34c28" class="tk">LIN0_TXMSG_SIZE</a>];</td></tr>
<tr name="35" id="35">
<td><a id="l35" class='ln'>35</a></td><td><span class="kw">void</span> <a id="35c6" class="tk">ec_lin_delay</a>(<a id="35c19" class="tk">uint32</a> <a id="35c26" class="tk">us</a>)</td></tr>
<tr name="36" id="36">
<td><a id="l36" class='ln'>36</a></td><td><span class="br">{</span></td></tr>
<tr name="37" id="37">
<td><a id="l37" class='ln'>37</a></td><td>  <a id="37c3" class="tk">uint32</a> <a id="37c10" class="tk">i</a>,<a id="37c12" class="tk">j</a>;</td></tr>
<tr name="38" id="38">
<td><a id="l38" class='ln'>38</a></td><td>  <span class="kw">for</span> (<a id="38c8" class="tk">i</a>=0; <a id="38c13" class="tk">i</a><a id="38c14" class="tk">&lt;</a><a id="38c15" class="tk">us</a>; <a id="38c19" class="tk">i</a><a id="38c20" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="39" id="39">
<td><a id="l39" class='ln'>39</a></td><td>    <span class="kw">for</span> (<a id="39c10" class="tk">j</a>=0; <a id="39c15" class="tk">j</a><a id="39c16" class="tk">&lt;</a>20; <a id="39c21" class="tk">j</a><a id="39c22" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="40" id="40">
<td><a id="l40" class='ln'>40</a></td><td>      <span class="kw">if</span> (1 <a id="40c13" class="tk">==</a> <a id="40c16" class="tk">LINFlexD_0</a>.<a id="40c27" class="tk">LINSR</a>.<a id="40c33" class="tk">B</a>.<a id="40c35" class="tk">DRF</a>) <span class="br">{</span></td></tr>
<tr name="41" id="41">
<td><a id="l41" class='ln'>41</a></td><td>        <a id="41c9" class="tk">i</a> = <a id="41c13" class="tk">us</a><a id="41c15" class="tk">+</a>1;</td></tr>
<tr name="42" id="42">
<td><a id="l42" class='ln'>42</a></td><td>        <a id="42c9" class="tk">j</a> = 21;</td></tr>
<tr name="43" id="43">
<td><a id="l43" class='ln'>43</a></td><td>      <span class="br">}</span></td></tr>
<tr name="44" id="44">
<td><a id="l44" class='ln'>44</a></td><td>    <span class="br">}</span></td></tr>
<tr name="45" id="45">
<td><a id="l45" class='ln'>45</a></td><td>  <span class="br">}</span></td></tr>
<tr name="46" id="46">
<td><a id="l46" class='ln'>46</a></td><td><span class="br">}</span></td></tr>
<tr name="47" id="47">
<td><a id="l47" class='ln'>47</a></td><td></td></tr>
<tr name="48" id="48">
<td><a id="l48" class='ln'>48</a></td><td><span class="kw">void</span> <a id="48c6" class="tk">ec_lin_init</a>(<span class="kw">void</span>)</td></tr>
<tr name="49" id="49">
<td><a id="l49" class='ln'>49</a></td><td><span class="br">{</span></td></tr>
<tr name="50" id="50">
<td><a id="l50" class='ln'>50</a></td><td>  <a id="50c3" class="tk">uint8</a> <a id="50c9" class="tk">i</a>;</td></tr>
<tr name="51" id="51">
<td><a id="l51" class='ln'>51</a></td><td>  <a id="51c3" class="tk">LINFlexD_0</a>.<a id="51c14" class="tk">LINCR1</a>.<a id="51c21" class="tk">R</a> = 0x0081;        <span class="ct">/* SLEEP=0, INIT=1 */</span></td></tr>
<tr name="52" id="52">
<td><a id="l52" class='ln'>52</a></td><td>  <span class="kw">while</span> (0x1000 <a id="52c17" class="tk">!=</a> (<a id="52c21" class="tk">LINFlexD_0</a>.<a id="52c32" class="tk">LINSR</a>.<a id="52c38" class="tk">R</a> <a id="52c40" class="tk">&amp;</a> 0xF000)) <span class="br">{</span></td></tr>
<tr name="53" id="53">
<td><a id="l53" class='ln'>53</a></td><td>  <span class="br">}</span></td></tr>
<tr name="54" id="54">
<td><a id="l54" class='ln'>54</a></td><td></td></tr>
<tr name="55" id="55">
<td><a id="l55" class='ln'>55</a></td><td>  <a id="55c3" class="tk">LINFlexD_0</a>.<a id="55c14" class="tk">LINFBRR</a>.<a id="55c22" class="tk">R</a> = 6;</td></tr>
<tr name="56" id="56">
<td><a id="l56" class='ln'>56</a></td><td>  <a id="56c3" class="tk">LINFlexD_0</a>.<a id="56c14" class="tk">LINIBRR</a>.<a id="56c22" class="tk">R</a> = 260;</td></tr>
<tr name="57" id="57">
<td><a id="l57" class='ln'>57</a></td><td>  <a id="57c3" class="tk">LINFlexD_0</a>.<a id="57c14" class="tk">LINCR2</a>.<a id="57c21" class="tk">R</a> = 0x40;   <span class="ct">/* IOBE=1, Bit error resets LIN state machine */</span></td></tr>
<tr name="58" id="58">
<td><a id="l58" class='ln'>58</a></td><td>  <a id="58c3" class="tk">LINFlexD_0</a>.<a id="58c14" class="tk">LINTCSR</a>.<a id="58c22" class="tk">R</a> = 0;           <span class="ct">/* LIN timeout mode, no idle on timeout */</span></td></tr>
<tr name="59" id="59">
<td><a id="l59" class='ln'>59</a></td><td>  <a id="59c3" class="tk">LINFlexD_0</a>.<a id="59c14" class="tk">LINCR2</a>.<a id="59c21" class="tk">R</a> = 0x00000800;</td></tr>
<tr name="60" id="60">
<td><a id="l60" class='ln'>60</a></td><td>  <a id="60c3" class="tk">ec_lin0_init_txdma</a>();</td></tr>
<tr name="61" id="61">
<td><a id="l61" class='ln'>61</a></td><td>  <a id="61c3" class="tk">LINFlexD_0</a>.<a id="61c14" class="tk">LINCR1</a>.<a id="61c21" class="tk">R</a> = 0x0390;</td></tr>
<tr name="62" id="62">
<td><a id="l62" class='ln'>62</a></td><td></td></tr>
<tr name="63" id="63">
<td><a id="l63" class='ln'>63</a></td><td>  <span class="ct">//LINFlexD_0.LINCR2.B.DDRQ = 1;</span></td></tr>
<tr name="64" id="64">
<td><a id="l64" class='ln'>64</a></td><td><span class="br">}</span></td></tr>
<tr name="65" id="65">
<td><a id="l65" class='ln'>65</a></td><td></td></tr>
<tr name="66" id="66">
<td><a id="l66" class='ln'>66</a></td><td><span class="kw">void</span> <a id="66c6" class="tk">ec_lin_transmit</a>(<a id="66c22" class="tk">uint8</a> <a id="66c28" class="tk">Tx_ID</a>, <a id="66c35" class="tk">uint8</a> <a id="66c41" class="tk">Datalength</a>, <a id="66c53" class="tk">uint8</a> <a id="66c59" class="tk">Tx_Data</a>[], <a id="66c70" class="tk">boolean</a></td></tr>
<tr name="67" id="67">
<td><a id="l67" class='ln'>67</a></td><td>                     <a id="67c22" class="tk">Checksum_Type</a>)</td></tr>
<tr name="68" id="68">
<td><a id="l68" class='ln'>68</a></td><td><span class="br">{</span></td></tr>
<tr name="69" id="69">
<td><a id="l69" class='ln'>69</a></td><td>  <span class="ct">/* store the data in the message buffer BDR */</span></td></tr>
<tr name="70" id="70">
<td><a id="l70" class='ln'>70</a></td><td>  <span class="kw">switch</span> (<a id="70c11" class="tk">Datalength</a>)</td></tr>
<tr name="71" id="71">
<td><a id="l71" class='ln'>71</a></td><td>  <span class="br">{</span></td></tr>
<tr name="72" id="72">
<td><a id="l72" class='ln'>72</a></td><td>   <span class="kw">case</span> 1<a id="72c10" class="tk">:</a></td></tr>
<tr name="73" id="73">
<td><a id="l73" class='ln'>73</a></td><td>    <a id="73c5" class="tk">LINFlexD_0</a>.<a id="73c16" class="tk">BDRL</a>.<a id="73c21" class="tk">B</a>.<a id="73c23" class="tk">DATA0</a> = <a id="73c31" class="tk">Tx_Data</a>[0];</td></tr>
<tr name="74" id="74">
<td><a id="l74" class='ln'>74</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="75" id="75">
<td><a id="l75" class='ln'>75</a></td><td></td></tr>
<tr name="76" id="76">
<td><a id="l76" class='ln'>76</a></td><td>   <span class="kw">case</span> 2<a id="76c10" class="tk">:</a></td></tr>
<tr name="77" id="77">
<td><a id="l77" class='ln'>77</a></td><td>    <a id="77c5" class="tk">LINFlexD_0</a>.<a id="77c16" class="tk">BDRL</a>.<a id="77c21" class="tk">B</a>.<a id="77c23" class="tk">DATA0</a> = <a id="77c31" class="tk">Tx_Data</a>[0];</td></tr>
<tr name="78" id="78">
<td><a id="l78" class='ln'>78</a></td><td>    <a id="78c5" class="tk">LINFlexD_0</a>.<a id="78c16" class="tk">BDRL</a>.<a id="78c21" class="tk">B</a>.<a id="78c23" class="tk">DATA1</a> = <a id="78c31" class="tk">Tx_Data</a>[1];</td></tr>
<tr name="79" id="79">
<td><a id="l79" class='ln'>79</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="80" id="80">
<td><a id="l80" class='ln'>80</a></td><td></td></tr>
<tr name="81" id="81">
<td><a id="l81" class='ln'>81</a></td><td>   <span class="kw">case</span> 3<a id="81c10" class="tk">:</a></td></tr>
<tr name="82" id="82">
<td><a id="l82" class='ln'>82</a></td><td>    <a id="82c5" class="tk">LINFlexD_0</a>.<a id="82c16" class="tk">BDRL</a>.<a id="82c21" class="tk">B</a>.<a id="82c23" class="tk">DATA0</a> = <a id="82c31" class="tk">Tx_Data</a>[0];</td></tr>
<tr name="83" id="83">
<td><a id="l83" class='ln'>83</a></td><td>    <a id="83c5" class="tk">LINFlexD_0</a>.<a id="83c16" class="tk">BDRL</a>.<a id="83c21" class="tk">B</a>.<a id="83c23" class="tk">DATA1</a> = <a id="83c31" class="tk">Tx_Data</a>[1];</td></tr>
<tr name="84" id="84">
<td><a id="l84" class='ln'>84</a></td><td>    <a id="84c5" class="tk">LINFlexD_0</a>.<a id="84c16" class="tk">BDRL</a>.<a id="84c21" class="tk">B</a>.<a id="84c23" class="tk">DATA2</a> = <a id="84c31" class="tk">Tx_Data</a>[2];</td></tr>
<tr name="85" id="85">
<td><a id="l85" class='ln'>85</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="86" id="86">
<td><a id="l86" class='ln'>86</a></td><td></td></tr>
<tr name="87" id="87">
<td><a id="l87" class='ln'>87</a></td><td>   <span class="kw">case</span> 4<a id="87c10" class="tk">:</a></td></tr>
<tr name="88" id="88">
<td><a id="l88" class='ln'>88</a></td><td>    <a id="88c5" class="tk">LINFlexD_0</a>.<a id="88c16" class="tk">BDRL</a>.<a id="88c21" class="tk">B</a>.<a id="88c23" class="tk">DATA0</a> = <a id="88c31" class="tk">Tx_Data</a>[0];</td></tr>
<tr name="89" id="89">
<td><a id="l89" class='ln'>89</a></td><td>    <a id="89c5" class="tk">LINFlexD_0</a>.<a id="89c16" class="tk">BDRL</a>.<a id="89c21" class="tk">B</a>.<a id="89c23" class="tk">DATA1</a> = <a id="89c31" class="tk">Tx_Data</a>[1];</td></tr>
<tr name="90" id="90">
<td><a id="l90" class='ln'>90</a></td><td>    <a id="90c5" class="tk">LINFlexD_0</a>.<a id="90c16" class="tk">BDRL</a>.<a id="90c21" class="tk">B</a>.<a id="90c23" class="tk">DATA2</a> = <a id="90c31" class="tk">Tx_Data</a>[2];</td></tr>
<tr name="91" id="91">
<td><a id="l91" class='ln'>91</a></td><td>    <a id="91c5" class="tk">LINFlexD_0</a>.<a id="91c16" class="tk">BDRL</a>.<a id="91c21" class="tk">B</a>.<a id="91c23" class="tk">DATA3</a> = <a id="91c31" class="tk">Tx_Data</a>[3];</td></tr>
<tr name="92" id="92">
<td><a id="l92" class='ln'>92</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="93" id="93">
<td><a id="l93" class='ln'>93</a></td><td></td></tr>
<tr name="94" id="94">
<td><a id="l94" class='ln'>94</a></td><td>   <span class="kw">case</span> 5<a id="94c10" class="tk">:</a></td></tr>
<tr name="95" id="95">
<td><a id="l95" class='ln'>95</a></td><td>    <a id="95c5" class="tk">LINFlexD_0</a>.<a id="95c16" class="tk">BDRL</a>.<a id="95c21" class="tk">B</a>.<a id="95c23" class="tk">DATA0</a> = <a id="95c31" class="tk">Tx_Data</a>[0];</td></tr>
<tr name="96" id="96">
<td><a id="l96" class='ln'>96</a></td><td>    <a id="96c5" class="tk">LINFlexD_0</a>.<a id="96c16" class="tk">BDRL</a>.<a id="96c21" class="tk">B</a>.<a id="96c23" class="tk">DATA1</a> = <a id="96c31" class="tk">Tx_Data</a>[1];</td></tr>
<tr name="97" id="97">
<td><a id="l97" class='ln'>97</a></td><td>    <a id="97c5" class="tk">LINFlexD_0</a>.<a id="97c16" class="tk">BDRL</a>.<a id="97c21" class="tk">B</a>.<a id="97c23" class="tk">DATA2</a> = <a id="97c31" class="tk">Tx_Data</a>[2];</td></tr>
<tr name="98" id="98">
<td><a id="l98" class='ln'>98</a></td><td>    <a id="98c5" class="tk">LINFlexD_0</a>.<a id="98c16" class="tk">BDRL</a>.<a id="98c21" class="tk">B</a>.<a id="98c23" class="tk">DATA3</a> = <a id="98c31" class="tk">Tx_Data</a>[3];</td></tr>
<tr name="99" id="99">
<td><a id="l99" class='ln'>99</a></td><td>    <a id="99c5" class="tk">LINFlexD_0</a>.<a id="99c16" class="tk">BDRM</a>.<a id="99c21" class="tk">B</a>.<a id="99c23" class="tk">DATA4</a> = <a id="99c31" class="tk">Tx_Data</a>[4];</td></tr>
<tr name="100" id="100">
<td><a id="l100" class='ln'>100</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="101" id="101">
<td><a id="l101" class='ln'>101</a></td><td></td></tr>
<tr name="102" id="102">
<td><a id="l102" class='ln'>102</a></td><td>   <span class="kw">case</span> 6<a id="102c10" class="tk">:</a></td></tr>
<tr name="103" id="103">
<td><a id="l103" class='ln'>103</a></td><td>    <a id="103c5" class="tk">LINFlexD_0</a>.<a id="103c16" class="tk">BDRL</a>.<a id="103c21" class="tk">B</a>.<a id="103c23" class="tk">DATA0</a> = <a id="103c31" class="tk">Tx_Data</a>[0];</td></tr>
<tr name="104" id="104">
<td><a id="l104" class='ln'>104</a></td><td>    <a id="104c5" class="tk">LINFlexD_0</a>.<a id="104c16" class="tk">BDRL</a>.<a id="104c21" class="tk">B</a>.<a id="104c23" class="tk">DATA1</a> = <a id="104c31" class="tk">Tx_Data</a>[1];</td></tr>
<tr name="105" id="105">
<td><a id="l105" class='ln'>105</a></td><td>    <a id="105c5" class="tk">LINFlexD_0</a>.<a id="105c16" class="tk">BDRL</a>.<a id="105c21" class="tk">B</a>.<a id="105c23" class="tk">DATA2</a> = <a id="105c31" class="tk">Tx_Data</a>[2];</td></tr>
<tr name="106" id="106">
<td><a id="l106" class='ln'>106</a></td><td>    <a id="106c5" class="tk">LINFlexD_0</a>.<a id="106c16" class="tk">BDRL</a>.<a id="106c21" class="tk">B</a>.<a id="106c23" class="tk">DATA3</a> = <a id="106c31" class="tk">Tx_Data</a>[3];</td></tr>
<tr name="107" id="107">
<td><a id="l107" class='ln'>107</a></td><td>    <a id="107c5" class="tk">LINFlexD_0</a>.<a id="107c16" class="tk">BDRM</a>.<a id="107c21" class="tk">B</a>.<a id="107c23" class="tk">DATA4</a> = <a id="107c31" class="tk">Tx_Data</a>[4];</td></tr>
<tr name="108" id="108">
<td><a id="l108" class='ln'>108</a></td><td>    <a id="108c5" class="tk">LINFlexD_0</a>.<a id="108c16" class="tk">BDRM</a>.<a id="108c21" class="tk">B</a>.<a id="108c23" class="tk">DATA5</a> = <a id="108c31" class="tk">Tx_Data</a>[5];</td></tr>
<tr name="109" id="109">
<td><a id="l109" class='ln'>109</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="110" id="110">
<td><a id="l110" class='ln'>110</a></td><td></td></tr>
<tr name="111" id="111">
<td><a id="l111" class='ln'>111</a></td><td>   <span class="kw">case</span> 7<a id="111c10" class="tk">:</a></td></tr>
<tr name="112" id="112">
<td><a id="l112" class='ln'>112</a></td><td>    <a id="112c5" class="tk">LINFlexD_0</a>.<a id="112c16" class="tk">BDRL</a>.<a id="112c21" class="tk">B</a>.<a id="112c23" class="tk">DATA0</a> = <a id="112c31" class="tk">Tx_Data</a>[0];</td></tr>
<tr name="113" id="113">
<td><a id="l113" class='ln'>113</a></td><td>    <a id="113c5" class="tk">LINFlexD_0</a>.<a id="113c16" class="tk">BDRL</a>.<a id="113c21" class="tk">B</a>.<a id="113c23" class="tk">DATA1</a> = <a id="113c31" class="tk">Tx_Data</a>[1];</td></tr>
<tr name="114" id="114">
<td><a id="l114" class='ln'>114</a></td><td>    <a id="114c5" class="tk">LINFlexD_0</a>.<a id="114c16" class="tk">BDRL</a>.<a id="114c21" class="tk">B</a>.<a id="114c23" class="tk">DATA2</a> = <a id="114c31" class="tk">Tx_Data</a>[2];</td></tr>
<tr name="115" id="115">
<td><a id="l115" class='ln'>115</a></td><td>    <a id="115c5" class="tk">LINFlexD_0</a>.<a id="115c16" class="tk">BDRL</a>.<a id="115c21" class="tk">B</a>.<a id="115c23" class="tk">DATA3</a> = <a id="115c31" class="tk">Tx_Data</a>[3];</td></tr>
<tr name="116" id="116">
<td><a id="l116" class='ln'>116</a></td><td>    <a id="116c5" class="tk">LINFlexD_0</a>.<a id="116c16" class="tk">BDRM</a>.<a id="116c21" class="tk">B</a>.<a id="116c23" class="tk">DATA4</a> = <a id="116c31" class="tk">Tx_Data</a>[4];</td></tr>
<tr name="117" id="117">
<td><a id="l117" class='ln'>117</a></td><td>    <a id="117c5" class="tk">LINFlexD_0</a>.<a id="117c16" class="tk">BDRM</a>.<a id="117c21" class="tk">B</a>.<a id="117c23" class="tk">DATA5</a> = <a id="117c31" class="tk">Tx_Data</a>[5];</td></tr>
<tr name="118" id="118">
<td><a id="l118" class='ln'>118</a></td><td>    <a id="118c5" class="tk">LINFlexD_0</a>.<a id="118c16" class="tk">BDRM</a>.<a id="118c21" class="tk">B</a>.<a id="118c23" class="tk">DATA6</a> = <a id="118c31" class="tk">Tx_Data</a>[6];</td></tr>
<tr name="119" id="119">
<td><a id="l119" class='ln'>119</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="120" id="120">
<td><a id="l120" class='ln'>120</a></td><td></td></tr>
<tr name="121" id="121">
<td><a id="l121" class='ln'>121</a></td><td>   <span class="kw">case</span> 8<a id="121c10" class="tk">:</a></td></tr>
<tr name="122" id="122">
<td><a id="l122" class='ln'>122</a></td><td>    <a id="122c5" class="tk">LINFlexD_0</a>.<a id="122c16" class="tk">BDRL</a>.<a id="122c21" class="tk">B</a>.<a id="122c23" class="tk">DATA0</a> = <a id="122c31" class="tk">Tx_Data</a>[0];</td></tr>
<tr name="123" id="123">
<td><a id="l123" class='ln'>123</a></td><td>    <a id="123c5" class="tk">LINFlexD_0</a>.<a id="123c16" class="tk">BDRL</a>.<a id="123c21" class="tk">B</a>.<a id="123c23" class="tk">DATA1</a> = <a id="123c31" class="tk">Tx_Data</a>[1];</td></tr>
<tr name="124" id="124">
<td><a id="l124" class='ln'>124</a></td><td>    <a id="124c5" class="tk">LINFlexD_0</a>.<a id="124c16" class="tk">BDRL</a>.<a id="124c21" class="tk">B</a>.<a id="124c23" class="tk">DATA2</a> = <a id="124c31" class="tk">Tx_Data</a>[2];</td></tr>
<tr name="125" id="125">
<td><a id="l125" class='ln'>125</a></td><td>    <a id="125c5" class="tk">LINFlexD_0</a>.<a id="125c16" class="tk">BDRL</a>.<a id="125c21" class="tk">B</a>.<a id="125c23" class="tk">DATA3</a> = <a id="125c31" class="tk">Tx_Data</a>[3];</td></tr>
<tr name="126" id="126">
<td><a id="l126" class='ln'>126</a></td><td>    <a id="126c5" class="tk">LINFlexD_0</a>.<a id="126c16" class="tk">BDRM</a>.<a id="126c21" class="tk">B</a>.<a id="126c23" class="tk">DATA4</a> = <a id="126c31" class="tk">Tx_Data</a>[4];</td></tr>
<tr name="127" id="127">
<td><a id="l127" class='ln'>127</a></td><td>    <a id="127c5" class="tk">LINFlexD_0</a>.<a id="127c16" class="tk">BDRM</a>.<a id="127c21" class="tk">B</a>.<a id="127c23" class="tk">DATA5</a> = <a id="127c31" class="tk">Tx_Data</a>[5];</td></tr>
<tr name="128" id="128">
<td><a id="l128" class='ln'>128</a></td><td>    <a id="128c5" class="tk">LINFlexD_0</a>.<a id="128c16" class="tk">BDRM</a>.<a id="128c21" class="tk">B</a>.<a id="128c23" class="tk">DATA6</a> = <a id="128c31" class="tk">Tx_Data</a>[6];</td></tr>
<tr name="129" id="129">
<td><a id="l129" class='ln'>129</a></td><td>    <a id="129c5" class="tk">LINFlexD_0</a>.<a id="129c16" class="tk">BDRM</a>.<a id="129c21" class="tk">B</a>.<a id="129c23" class="tk">DATA7</a> = <a id="129c31" class="tk">Tx_Data</a>[7];</td></tr>
<tr name="130" id="130">
<td><a id="l130" class='ln'>130</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="131" id="131">
<td><a id="l131" class='ln'>131</a></td><td></td></tr>
<tr name="132" id="132">
<td><a id="l132" class='ln'>132</a></td><td>   <span class="kw">default</span> <a id="132c12" class="tk">:</a></td></tr>
<tr name="133" id="133">
<td><a id="l133" class='ln'>133</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="134" id="134">
<td><a id="l134" class='ln'>134</a></td><td>  <span class="br">}</span></td></tr>
<tr name="135" id="135">
<td><a id="l135" class='ln'>135</a></td><td></td></tr>
<tr name="136" id="136">
<td><a id="l136" class='ln'>136</a></td><td>  <a id="136c3" class="tk">LINFlexD_0</a>.<a id="136c14" class="tk">BIDR</a>.<a id="136c19" class="tk">B</a>.<a id="136c21" class="tk">DFL</a> = <a id="136c27" class="tk">Datalength</a> <a id="136c38" class="tk">-</a> 1;<span class="ct">/* DFL = Number of data bytes - 1 */</span></td></tr>
<tr name="137" id="137">
<td><a id="l137" class='ln'>137</a></td><td>  <a id="137c3" class="tk">LINFlexD_0</a>.<a id="137c14" class="tk">BIDR</a>.<a id="137c19" class="tk">B</a>.<a id="137c21" class="tk">DIR</a> = 1;</td></tr>
<tr name="138" id="138">
<td><a id="l138" class='ln'>138</a></td><td>                        <span class="ct">/* LINFlexD transmits the data from the BDR registers */</span></td></tr>
<tr name="139" id="139">
<td><a id="l139" class='ln'>139</a></td><td>  <a id="139c3" class="tk">LINFlexD_0</a>.<a id="139c14" class="tk">BIDR</a>.<a id="139c19" class="tk">B</a>.<a id="139c21" class="tk">CCS</a> = <a id="139c27" class="tk">Checksum_Type</a>;</td></tr>
<tr name="140" id="140">
<td><a id="l140" class='ln'>140</a></td><td>                                <span class="ct">/* 0: Enhanced Checksum ; 1: Classic Checksum */</span></td></tr>
<tr name="141" id="141">
<td><a id="l141" class='ln'>141</a></td><td>  <a id="141c3" class="tk">LINFlexD_0</a>.<a id="141c14" class="tk">BIDR</a>.<a id="141c19" class="tk">B</a>.<a id="141c21" class="tk">ID</a> = <a id="141c26" class="tk">Tx_ID</a>; <span class="ct">/* 0: Enhanced Checksum ; 1: Classic Checksum */</span></td></tr>
<tr name="142" id="142">
<td><a id="l142" class='ln'>142</a></td><td>  <a id="142c3" class="tk">LINFlexD_0</a>.<a id="142c14" class="tk">LINCR2</a>.<a id="142c21" class="tk">B</a>.<a id="142c23" class="tk">HTRQ</a> = 1;        <span class="ct">/* Trigger Frame transmission */</span></td></tr>
<tr name="143" id="143">
<td><a id="l143" class='ln'>143</a></td><td></td></tr>
<tr name="144" id="144">
<td><a id="l144" class='ln'>144</a></td><td>  <span class="ct">/* wait until Master response to the LIN header has been sent successfully */</span></td></tr>
<tr name="145" id="145">
<td><a id="l145" class='ln'>145</a></td><td>  <span class="kw">while</span> (0 <a id="145c12" class="tk">==</a> <a id="145c15" class="tk">LINFlexD_0</a>.<a id="145c26" class="tk">LINSR</a>.<a id="145c32" class="tk">B</a>.<a id="145c34" class="tk">DTF</a>) <span class="br">{</span></td></tr>
<tr name="146" id="146">
<td><a id="l146" class='ln'>146</a></td><td>    <span class="ct">/* track LIN Status for errors */</span></td></tr>
<tr name="147" id="147">
<td><a id="l147" class='ln'>147</a></td><td>  <span class="br">}</span></td></tr>
<tr name="148" id="148">
<td><a id="l148" class='ln'>148</a></td><td></td></tr>
<tr name="149" id="149">
<td><a id="l149" class='ln'>149</a></td><td>  <a id="149c3" class="tk">LINFlexD_0</a>.<a id="149c14" class="tk">LINSR</a>.<a id="149c20" class="tk">R</a> = 0x0002;         <span class="ct">/* clear the DTF bit */</span></td></tr>
<tr name="150" id="150">
<td><a id="l150" class='ln'>150</a></td><td><span class="br">}</span></td></tr>
<tr name="151" id="151">
<td><a id="l151" class='ln'>151</a></td><td></td></tr>
<tr name="152" id="152">
<td><a id="l152" class='ln'>152</a></td><td><span class="kw">void</span> <a id="152c6" class="tk">ec_lin_receive</a>(<a id="152c21" class="tk">uint8</a> <a id="152c27" class="tk">Rx_ID</a>, <a id="152c34" class="tk">uint8</a> <a id="152c40" class="tk">Datalength</a>, <a id="152c52" class="tk">uint8</a> <a id="152c58" class="tk">Rx_Buffer</a>[], <a id="152c71" class="tk">boolean</a></td></tr>
<tr name="153" id="153">
<td><a id="l153" class='ln'>153</a></td><td>                    <a id="153c21" class="tk">Checksum_Type</a>)</td></tr>
<tr name="154" id="154">
<td><a id="l154" class='ln'>154</a></td><td><span class="br">{</span></td></tr>
<tr name="155" id="155">
<td><a id="l155" class='ln'>155</a></td><td>  <a id="155c3" class="tk">LIN0_RXMSG_ACTIVE</a> = 1;</td></tr>
<tr name="156" id="156">
<td><a id="l156" class='ln'>156</a></td><td>  <a id="156c3" class="tk">LINFlexD_0</a>.<a id="156c14" class="tk">BIDR</a>.<a id="156c19" class="tk">B</a>.<a id="156c21" class="tk">DFL</a> = <a id="156c27" class="tk">Datalength</a> <a id="156c38" class="tk">-</a> 1;<span class="ct">/* DFL = Number of data bytes - 1 */</span></td></tr>
<tr name="157" id="157">
<td><a id="l157" class='ln'>157</a></td><td>  <a id="157c3" class="tk">LINFlexD_0</a>.<a id="157c14" class="tk">BIDR</a>.<a id="157c19" class="tk">B</a>.<a id="157c21" class="tk">DIR</a> = 0;</td></tr>
<tr name="158" id="158">
<td><a id="l158" class='ln'>158</a></td><td>             <span class="ct">/* LINFlexD receives the data and copy them in the BDR registers */</span></td></tr>
<tr name="159" id="159">
<td><a id="l159" class='ln'>159</a></td><td>  <a id="159c3" class="tk">LINFlexD_0</a>.<a id="159c14" class="tk">BIDR</a>.<a id="159c19" class="tk">B</a>.<a id="159c21" class="tk">CCS</a> = <a id="159c27" class="tk">Checksum_Type</a>;</td></tr>
<tr name="160" id="160">
<td><a id="l160" class='ln'>160</a></td><td>                                <span class="ct">/* 0: Enhanced Checksum ; 1: Classic Checksum */</span></td></tr>
<tr name="161" id="161">
<td><a id="l161" class='ln'>161</a></td><td>  <a id="161c3" class="tk">LINFlexD_0</a>.<a id="161c14" class="tk">BIDR</a>.<a id="161c19" class="tk">B</a>.<a id="161c21" class="tk">ID</a> = <a id="161c26" class="tk">Rx_ID</a>; <span class="ct">/* 0: Enhanced Checksum ; 1: Classic Checksum */</span></td></tr>
<tr name="162" id="162">
<td><a id="l162" class='ln'>162</a></td><td>  <a id="162c3" class="tk">LINFlexD_0</a>.<a id="162c14" class="tk">LINCR2</a>.<a id="162c21" class="tk">B</a>.<a id="162c23" class="tk">HTRQ</a> = 1;        <span class="ct">/* Trigger Frame transmission */</span></td></tr>
<tr name="163" id="163">
<td><a id="l163" class='ln'>163</a></td><td></td></tr>
<tr name="164" id="164">
<td><a id="l164" class='ln'>164</a></td><td>  <span class="ct">/* wait until Slave response to the LIN header has been receive successfully */</span></td></tr>
<tr name="165" id="165">
<td><a id="l165" class='ln'>165</a></td><td>  <a id="165c3" class="tk">ec_lin_delay</a>(1000);</td></tr>
<tr name="166" id="166">
<td><a id="l166" class='ln'>166</a></td><td></td></tr>
<tr name="167" id="167">
<td><a id="l167" class='ln'>167</a></td><td>  <span class="ct">/* read BDR registers */</span></td></tr>
<tr name="168" id="168">
<td><a id="l168" class='ln'>168</a></td><td>  <span class="kw">switch</span> (<a id="168c11" class="tk">Datalength</a>)</td></tr>
<tr name="169" id="169">
<td><a id="l169" class='ln'>169</a></td><td>  <span class="br">{</span></td></tr>
<tr name="170" id="170">
<td><a id="l170" class='ln'>170</a></td><td>   <span class="kw">case</span> 1<a id="170c10" class="tk">:</a></td></tr>
<tr name="171" id="171">
<td><a id="l171" class='ln'>171</a></td><td>    <a id="171c5" class="tk">Rx_Buffer</a>[0] = <a id="171c20" class="tk">LINFlexD_0</a>.<a id="171c31" class="tk">BDRL</a>.<a id="171c36" class="tk">B</a>.<a id="171c38" class="tk">DATA0</a>;</td></tr>
<tr name="172" id="172">
<td><a id="l172" class='ln'>172</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="173" id="173">
<td><a id="l173" class='ln'>173</a></td><td></td></tr>
<tr name="174" id="174">
<td><a id="l174" class='ln'>174</a></td><td>   <span class="kw">case</span> 2<a id="174c10" class="tk">:</a></td></tr>
<tr name="175" id="175">
<td><a id="l175" class='ln'>175</a></td><td>    <a id="175c5" class="tk">Rx_Buffer</a>[0] = <a id="175c20" class="tk">LINFlexD_0</a>.<a id="175c31" class="tk">BDRL</a>.<a id="175c36" class="tk">B</a>.<a id="175c38" class="tk">DATA0</a>;</td></tr>
<tr name="176" id="176">
<td><a id="l176" class='ln'>176</a></td><td>    <a id="176c5" class="tk">Rx_Buffer</a>[1] = <a id="176c20" class="tk">LINFlexD_0</a>.<a id="176c31" class="tk">BDRL</a>.<a id="176c36" class="tk">B</a>.<a id="176c38" class="tk">DATA1</a>;</td></tr>
<tr name="177" id="177">
<td><a id="l177" class='ln'>177</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="178" id="178">
<td><a id="l178" class='ln'>178</a></td><td></td></tr>
<tr name="179" id="179">
<td><a id="l179" class='ln'>179</a></td><td>   <span class="kw">case</span> 3<a id="179c10" class="tk">:</a></td></tr>
<tr name="180" id="180">
<td><a id="l180" class='ln'>180</a></td><td>    <a id="180c5" class="tk">Rx_Buffer</a>[0] = <a id="180c20" class="tk">LINFlexD_0</a>.<a id="180c31" class="tk">BDRL</a>.<a id="180c36" class="tk">B</a>.<a id="180c38" class="tk">DATA0</a>;</td></tr>
<tr name="181" id="181">
<td><a id="l181" class='ln'>181</a></td><td>    <a id="181c5" class="tk">Rx_Buffer</a>[1] = <a id="181c20" class="tk">LINFlexD_0</a>.<a id="181c31" class="tk">BDRL</a>.<a id="181c36" class="tk">B</a>.<a id="181c38" class="tk">DATA1</a>;</td></tr>
<tr name="182" id="182">
<td><a id="l182" class='ln'>182</a></td><td>    <a id="182c5" class="tk">Rx_Buffer</a>[2] = <a id="182c20" class="tk">LINFlexD_0</a>.<a id="182c31" class="tk">BDRL</a>.<a id="182c36" class="tk">B</a>.<a id="182c38" class="tk">DATA2</a>;</td></tr>
<tr name="183" id="183">
<td><a id="l183" class='ln'>183</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="184" id="184">
<td><a id="l184" class='ln'>184</a></td><td></td></tr>
<tr name="185" id="185">
<td><a id="l185" class='ln'>185</a></td><td>   <span class="kw">case</span> 4<a id="185c10" class="tk">:</a></td></tr>
<tr name="186" id="186">
<td><a id="l186" class='ln'>186</a></td><td>    <a id="186c5" class="tk">Rx_Buffer</a>[0] = <a id="186c20" class="tk">LINFlexD_0</a>.<a id="186c31" class="tk">BDRL</a>.<a id="186c36" class="tk">B</a>.<a id="186c38" class="tk">DATA0</a>;</td></tr>
<tr name="187" id="187">
<td><a id="l187" class='ln'>187</a></td><td>    <a id="187c5" class="tk">Rx_Buffer</a>[1] = <a id="187c20" class="tk">LINFlexD_0</a>.<a id="187c31" class="tk">BDRL</a>.<a id="187c36" class="tk">B</a>.<a id="187c38" class="tk">DATA1</a>;</td></tr>
<tr name="188" id="188">
<td><a id="l188" class='ln'>188</a></td><td>    <a id="188c5" class="tk">Rx_Buffer</a>[2] = <a id="188c20" class="tk">LINFlexD_0</a>.<a id="188c31" class="tk">BDRL</a>.<a id="188c36" class="tk">B</a>.<a id="188c38" class="tk">DATA2</a>;</td></tr>
<tr name="189" id="189">
<td><a id="l189" class='ln'>189</a></td><td>    <a id="189c5" class="tk">Rx_Buffer</a>[3] = <a id="189c20" class="tk">LINFlexD_0</a>.<a id="189c31" class="tk">BDRL</a>.<a id="189c36" class="tk">B</a>.<a id="189c38" class="tk">DATA3</a>;</td></tr>
<tr name="190" id="190">
<td><a id="l190" class='ln'>190</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="191" id="191">
<td><a id="l191" class='ln'>191</a></td><td></td></tr>
<tr name="192" id="192">
<td><a id="l192" class='ln'>192</a></td><td>   <span class="kw">case</span> 5<a id="192c10" class="tk">:</a></td></tr>
<tr name="193" id="193">
<td><a id="l193" class='ln'>193</a></td><td>    <a id="193c5" class="tk">Rx_Buffer</a>[0] = <a id="193c20" class="tk">LINFlexD_0</a>.<a id="193c31" class="tk">BDRL</a>.<a id="193c36" class="tk">B</a>.<a id="193c38" class="tk">DATA0</a>;</td></tr>
<tr name="194" id="194">
<td><a id="l194" class='ln'>194</a></td><td>    <a id="194c5" class="tk">Rx_Buffer</a>[1] = <a id="194c20" class="tk">LINFlexD_0</a>.<a id="194c31" class="tk">BDRL</a>.<a id="194c36" class="tk">B</a>.<a id="194c38" class="tk">DATA1</a>;</td></tr>
<tr name="195" id="195">
<td><a id="l195" class='ln'>195</a></td><td>    <a id="195c5" class="tk">Rx_Buffer</a>[2] = <a id="195c20" class="tk">LINFlexD_0</a>.<a id="195c31" class="tk">BDRL</a>.<a id="195c36" class="tk">B</a>.<a id="195c38" class="tk">DATA2</a>;</td></tr>
<tr name="196" id="196">
<td><a id="l196" class='ln'>196</a></td><td>    <a id="196c5" class="tk">Rx_Buffer</a>[3] = <a id="196c20" class="tk">LINFlexD_0</a>.<a id="196c31" class="tk">BDRL</a>.<a id="196c36" class="tk">B</a>.<a id="196c38" class="tk">DATA3</a>;</td></tr>
<tr name="197" id="197">
<td><a id="l197" class='ln'>197</a></td><td>    <a id="197c5" class="tk">Rx_Buffer</a>[4] = <a id="197c20" class="tk">LINFlexD_0</a>.<a id="197c31" class="tk">BDRM</a>.<a id="197c36" class="tk">B</a>.<a id="197c38" class="tk">DATA4</a>;</td></tr>
<tr name="198" id="198">
<td><a id="l198" class='ln'>198</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="199" id="199">
<td><a id="l199" class='ln'>199</a></td><td></td></tr>
<tr name="200" id="200">
<td><a id="l200" class='ln'>200</a></td><td>   <span class="kw">case</span> 6<a id="200c10" class="tk">:</a></td></tr>
<tr name="201" id="201">
<td><a id="l201" class='ln'>201</a></td><td>    <a id="201c5" class="tk">Rx_Buffer</a>[0] = <a id="201c20" class="tk">LINFlexD_0</a>.<a id="201c31" class="tk">BDRL</a>.<a id="201c36" class="tk">B</a>.<a id="201c38" class="tk">DATA0</a>;</td></tr>
<tr name="202" id="202">
<td><a id="l202" class='ln'>202</a></td><td>    <a id="202c5" class="tk">Rx_Buffer</a>[1] = <a id="202c20" class="tk">LINFlexD_0</a>.<a id="202c31" class="tk">BDRL</a>.<a id="202c36" class="tk">B</a>.<a id="202c38" class="tk">DATA1</a>;</td></tr>
<tr name="203" id="203">
<td><a id="l203" class='ln'>203</a></td><td>    <a id="203c5" class="tk">Rx_Buffer</a>[2] = <a id="203c20" class="tk">LINFlexD_0</a>.<a id="203c31" class="tk">BDRL</a>.<a id="203c36" class="tk">B</a>.<a id="203c38" class="tk">DATA2</a>;</td></tr>
<tr name="204" id="204">
<td><a id="l204" class='ln'>204</a></td><td>    <a id="204c5" class="tk">Rx_Buffer</a>[3] = <a id="204c20" class="tk">LINFlexD_0</a>.<a id="204c31" class="tk">BDRL</a>.<a id="204c36" class="tk">B</a>.<a id="204c38" class="tk">DATA3</a>;</td></tr>
<tr name="205" id="205">
<td><a id="l205" class='ln'>205</a></td><td>    <a id="205c5" class="tk">Rx_Buffer</a>[4] = <a id="205c20" class="tk">LINFlexD_0</a>.<a id="205c31" class="tk">BDRM</a>.<a id="205c36" class="tk">B</a>.<a id="205c38" class="tk">DATA4</a>;</td></tr>
<tr name="206" id="206">
<td><a id="l206" class='ln'>206</a></td><td>    <a id="206c5" class="tk">Rx_Buffer</a>[5] = <a id="206c20" class="tk">LINFlexD_0</a>.<a id="206c31" class="tk">BDRM</a>.<a id="206c36" class="tk">B</a>.<a id="206c38" class="tk">DATA5</a>;</td></tr>
<tr name="207" id="207">
<td><a id="l207" class='ln'>207</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="208" id="208">
<td><a id="l208" class='ln'>208</a></td><td></td></tr>
<tr name="209" id="209">
<td><a id="l209" class='ln'>209</a></td><td>   <span class="kw">case</span> 7<a id="209c10" class="tk">:</a></td></tr>
<tr name="210" id="210">
<td><a id="l210" class='ln'>210</a></td><td>    <a id="210c5" class="tk">Rx_Buffer</a>[0] = <a id="210c20" class="tk">LINFlexD_0</a>.<a id="210c31" class="tk">BDRL</a>.<a id="210c36" class="tk">B</a>.<a id="210c38" class="tk">DATA0</a>;</td></tr>
<tr name="211" id="211">
<td><a id="l211" class='ln'>211</a></td><td>    <a id="211c5" class="tk">Rx_Buffer</a>[1] = <a id="211c20" class="tk">LINFlexD_0</a>.<a id="211c31" class="tk">BDRL</a>.<a id="211c36" class="tk">B</a>.<a id="211c38" class="tk">DATA1</a>;</td></tr>
<tr name="212" id="212">
<td><a id="l212" class='ln'>212</a></td><td>    <a id="212c5" class="tk">Rx_Buffer</a>[2] = <a id="212c20" class="tk">LINFlexD_0</a>.<a id="212c31" class="tk">BDRL</a>.<a id="212c36" class="tk">B</a>.<a id="212c38" class="tk">DATA2</a>;</td></tr>
<tr name="213" id="213">
<td><a id="l213" class='ln'>213</a></td><td>    <a id="213c5" class="tk">Rx_Buffer</a>[3] = <a id="213c20" class="tk">LINFlexD_0</a>.<a id="213c31" class="tk">BDRL</a>.<a id="213c36" class="tk">B</a>.<a id="213c38" class="tk">DATA3</a>;</td></tr>
<tr name="214" id="214">
<td><a id="l214" class='ln'>214</a></td><td>    <a id="214c5" class="tk">Rx_Buffer</a>[4] = <a id="214c20" class="tk">LINFlexD_0</a>.<a id="214c31" class="tk">BDRM</a>.<a id="214c36" class="tk">B</a>.<a id="214c38" class="tk">DATA4</a>;</td></tr>
<tr name="215" id="215">
<td><a id="l215" class='ln'>215</a></td><td>    <a id="215c5" class="tk">Rx_Buffer</a>[5] = <a id="215c20" class="tk">LINFlexD_0</a>.<a id="215c31" class="tk">BDRM</a>.<a id="215c36" class="tk">B</a>.<a id="215c38" class="tk">DATA5</a>;</td></tr>
<tr name="216" id="216">
<td><a id="l216" class='ln'>216</a></td><td>    <a id="216c5" class="tk">Rx_Buffer</a>[6] = <a id="216c20" class="tk">LINFlexD_0</a>.<a id="216c31" class="tk">BDRM</a>.<a id="216c36" class="tk">B</a>.<a id="216c38" class="tk">DATA6</a>;</td></tr>
<tr name="217" id="217">
<td><a id="l217" class='ln'>217</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="218" id="218">
<td><a id="l218" class='ln'>218</a></td><td></td></tr>
<tr name="219" id="219">
<td><a id="l219" class='ln'>219</a></td><td>   <span class="kw">case</span> 8<a id="219c10" class="tk">:</a></td></tr>
<tr name="220" id="220">
<td><a id="l220" class='ln'>220</a></td><td>    <a id="220c5" class="tk">Rx_Buffer</a>[0] = <a id="220c20" class="tk">LINFlexD_0</a>.<a id="220c31" class="tk">BDRL</a>.<a id="220c36" class="tk">B</a>.<a id="220c38" class="tk">DATA0</a>;</td></tr>
<tr name="221" id="221">
<td><a id="l221" class='ln'>221</a></td><td>    <a id="221c5" class="tk">Rx_Buffer</a>[1] = <a id="221c20" class="tk">LINFlexD_0</a>.<a id="221c31" class="tk">BDRL</a>.<a id="221c36" class="tk">B</a>.<a id="221c38" class="tk">DATA1</a>;</td></tr>
<tr name="222" id="222">
<td><a id="l222" class='ln'>222</a></td><td>    <a id="222c5" class="tk">Rx_Buffer</a>[2] = <a id="222c20" class="tk">LINFlexD_0</a>.<a id="222c31" class="tk">BDRL</a>.<a id="222c36" class="tk">B</a>.<a id="222c38" class="tk">DATA2</a>;</td></tr>
<tr name="223" id="223">
<td><a id="l223" class='ln'>223</a></td><td>    <a id="223c5" class="tk">Rx_Buffer</a>[3] = <a id="223c20" class="tk">LINFlexD_0</a>.<a id="223c31" class="tk">BDRL</a>.<a id="223c36" class="tk">B</a>.<a id="223c38" class="tk">DATA3</a>;</td></tr>
<tr name="224" id="224">
<td><a id="l224" class='ln'>224</a></td><td>    <a id="224c5" class="tk">Rx_Buffer</a>[4] = <a id="224c20" class="tk">LINFlexD_0</a>.<a id="224c31" class="tk">BDRM</a>.<a id="224c36" class="tk">B</a>.<a id="224c38" class="tk">DATA4</a>;</td></tr>
<tr name="225" id="225">
<td><a id="l225" class='ln'>225</a></td><td>    <a id="225c5" class="tk">Rx_Buffer</a>[5] = <a id="225c20" class="tk">LINFlexD_0</a>.<a id="225c31" class="tk">BDRM</a>.<a id="225c36" class="tk">B</a>.<a id="225c38" class="tk">DATA5</a>;</td></tr>
<tr name="226" id="226">
<td><a id="l226" class='ln'>226</a></td><td>    <a id="226c5" class="tk">Rx_Buffer</a>[6] = <a id="226c20" class="tk">LINFlexD_0</a>.<a id="226c31" class="tk">BDRM</a>.<a id="226c36" class="tk">B</a>.<a id="226c38" class="tk">DATA6</a>;</td></tr>
<tr name="227" id="227">
<td><a id="l227" class='ln'>227</a></td><td>    <a id="227c5" class="tk">Rx_Buffer</a>[7] = <a id="227c20" class="tk">LINFlexD_0</a>.<a id="227c31" class="tk">BDRM</a>.<a id="227c36" class="tk">B</a>.<a id="227c38" class="tk">DATA7</a>;</td></tr>
<tr name="228" id="228">
<td><a id="l228" class='ln'>228</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="229" id="229">
<td><a id="l229" class='ln'>229</a></td><td></td></tr>
<tr name="230" id="230">
<td><a id="l230" class='ln'>230</a></td><td>   <span class="kw">default</span> <a id="230c12" class="tk">:</a></td></tr>
<tr name="231" id="231">
<td><a id="l231" class='ln'>231</a></td><td>    <span class="kw">break</span>;</td></tr>
<tr name="232" id="232">
<td><a id="l232" class='ln'>232</a></td><td>  <span class="br">}</span></td></tr>
<tr name="233" id="233">
<td><a id="l233" class='ln'>233</a></td><td></td></tr>
<tr name="234" id="234">
<td><a id="l234" class='ln'>234</a></td><td>  <a id="234c3" class="tk">LINFlexD_0</a>.<a id="234c14" class="tk">LINSR</a>.<a id="234c20" class="tk">R</a> = 0x0207;         <span class="ct">/* clear RMB, HRF, DRF and DTF flags */</span></td></tr>
<tr name="235" id="235">
<td><a id="l235" class='ln'>235</a></td><td>  <a id="235c3" class="tk">LIN0_RXMSG_ACTIVE</a> = 0;</td></tr>
<tr name="236" id="236">
<td><a id="l236" class='ln'>236</a></td><td><span class="br">}</span></td></tr>
<tr name="237" id="237">
<td><a id="l237" class='ln'>237</a></td><td></td></tr>
<tr name="238" id="238">
<td><a id="l238" class='ln'>238</a></td><td><span class="ct">/*****************************************************************************************</span></td></tr>
<tr name="239" id="239">
<td><a id="l239" class='ln'>239</a></td><td><span class="ct"> *                        LIN-Tx DMA模式下工作</span></td></tr>
<tr name="240" id="240">
<td><a id="l240" class='ln'>240</a></td><td><span class="ct"> ****************************************************************************************/</span></td></tr>
<tr name="241" id="241">
<td><a id="l241" class='ln'>241</a></td><td></td></tr>
<tr name="242" id="242">
<td><a id="l242" class='ln'>242</a></td><td><span class="ct">/*</span></td></tr>
<tr name="243" id="243">
<td><a id="l243" class='ln'>243</a></td><td><span class="ct"> *   LIN-Tx DMA Init</span></td></tr>
<tr name="244" id="244">
<td><a id="l244" class='ln'>244</a></td><td><span class="ct"> */</span></td></tr>
<tr name="245" id="245">
<td><a id="l245" class='ln'>245</a></td><td><span class="kw">void</span> <a id="245c6" class="tk">ec_lin0_init_txdma</a>(<span class="kw">void</span>)</td></tr>
<tr name="246" id="246">
<td><a id="l246" class='ln'>246</a></td><td><span class="br">{</span></td></tr>
<tr name="247" id="247">
<td><a id="l247" class='ln'>247</a></td><td>  <a id="247c3" class="tk">XBAR_0</a>.<a id="247c10" class="tk">PORT</a>[4].<a id="247c18" class="tk">PRS</a>.<a id="247c22" class="tk">R</a> = 0x03000021;   <span class="ct">//配置DMA对外设桥0访问具有最高优先级</span></td></tr>
<tr name="248" id="248">
<td><a id="l248" class='ln'>248</a></td><td>  <a id="248c3" class="tk">AIPS_0</a>.<a id="248c10" class="tk">MPRA</a>.<a id="248c15" class="tk">R</a> <a id="248c17" class="tk">|=</a> 0x77777770;         <span class="ct">//配置所有主机对外设桥0具有读、写权限</span></td></tr>
<tr name="249" id="249">
<td><a id="l249" class='ln'>249</a></td><td>  <a id="249c3" class="tk">AIPS_1</a>.<a id="249c10" class="tk">MPRA</a>.<a id="249c15" class="tk">R</a> <a id="249c17" class="tk">|=</a> 0x77777770;         <span class="ct">//配置所有主机对外设桥1具有读、写权限</span></td></tr>
<tr name="250" id="250">
<td><a id="l250" class='ln'>250</a></td><td></td></tr>
<tr name="251" id="251">
<td><a id="l251" class='ln'>251</a></td><td>  <span class="ct">/* Init eDMA engine */</span></td></tr>
<tr name="252" id="252">
<td><a id="l252" class='ln'>252</a></td><td>  <a id="252c3" class="tk">DMA_0</a>.<a id="252c9" class="tk">CR</a>.<a id="252c12" class="tk">B</a>.<a id="252c14" class="tk">HALT</a>= 1;                  <span class="ct">//停止DMA传输</span></td></tr>
<tr name="253" id="253">
<td><a id="l253" class='ln'>253</a></td><td></td></tr>
<tr name="254" id="254">
<td><a id="l254" class='ln'>254</a></td><td>  <span class="ct">/* cfg DMA_MUX for DMA channel 0 -- LIN0_COMBTX_DMACH */</span></td></tr>
<tr name="255" id="255">
<td><a id="l255" class='ln'>255</a></td><td>  <a id="255c3" class="tk">DMAMUX_0</a>.<a id="255c12" class="tk">CHCFG</a>[<a id="255c18" class="tk">LIN0_COMBTX_DMACH</a>].<a id="255c37" class="tk">R</a> = 0x80 <a id="255c46" class="tk">|</a> 0x14;</td></tr>
<tr name="256" id="256">
<td><a id="l256" class='ln'>256</a></td><td></td></tr>
<tr name="257" id="257">
<td><a id="l257" class='ln'>257</a></td><td>  <span class="ct">/* DMA_0 config for LIN_Tx */</span></td></tr>
<tr name="258" id="258">
<td><a id="l258" class='ln'>258</a></td><td>  <a id="258c3" class="tk">DMA_0</a>.<a id="258c9" class="tk">TCD</a>[<a id="258c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="258c32" class="tk">SADDR</a>.<a id="258c38" class="tk">R</a> = (<a id="258c43" class="tk">vuint32_t</a>) <a id="258c54" class="tk">&amp;</a><a id="258c55" class="tk">ec_lin_dma_info</a>;<span class="ct">//设置源地址</span></td></tr>
<tr name="259" id="259">
<td><a id="l259" class='ln'>259</a></td><td>  <a id="259c3" class="tk">DMA_0</a>.<a id="259c9" class="tk">TCD</a>[<a id="259c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="259c32" class="tk">SOFF</a>.<a id="259c37" class="tk">R</a> = 1;</td></tr>
<tr name="260" id="260">
<td><a id="l260" class='ln'>260</a></td><td>  <span class="ct">//设置minor loop步长，即每进行一次数据传输源地址增长数，以字节为1 ：1字节  2:2字节  4:4字节DMA_0.TCD[LIN0_COMBTX_DMACH].ATTR.B.SMOD = 0;                          //不选择源地址取模</span></td></tr>
<tr name="261" id="261">
<td><a id="l261" class='ln'>261</a></td><td>  <a id="261c3" class="tk">DMA_0</a>.<a id="261c9" class="tk">TCD</a>[<a id="261c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="261c32" class="tk">ATTR</a>.<a id="261c37" class="tk">B</a>.<a id="261c39" class="tk">SSIZE</a> = 0;<span class="ct">//源数据字节长，0:8-bit 1:16-bit 2:32-bit</span></td></tr>
<tr name="262" id="262">
<td><a id="l262" class='ln'>262</a></td><td>  <a id="262c3" class="tk">DMA_0</a>.<a id="262c9" class="tk">TCD</a>[<a id="262c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="262c32" class="tk">SLAST</a>.<a id="262c38" class="tk">R</a> = <a id="262c42" class="tk">-</a>12;</td></tr>
<tr name="263" id="263">
<td><a id="l263" class='ln'>263</a></td><td>        <span class="ct">//数据传输完后对源地址进行调整，完成后的地址加上该寄存器的值为最终源地址</span></td></tr>
<tr name="264" id="264">
<td><a id="l264" class='ln'>264</a></td><td>  <a id="264c3" class="tk">DMA_0</a>.<a id="264c9" class="tk">TCD</a>[<a id="264c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="264c32" class="tk">DADDR</a>.<a id="264c38" class="tk">R</a> = (<a id="264c43" class="tk">vuint32_t</a>)<a id="264c53" class="tk">&amp;</a><a id="264c54" class="tk">LINFlexD_0</a>.<a id="264c65" class="tk">BIDR</a>.<a id="264c70" class="tk">R</a>;<span class="ct">//设置目的地址</span></td></tr>
<tr name="265" id="265">
<td><a id="l265" class='ln'>265</a></td><td>  <a id="265c3" class="tk">DMA_0</a>.<a id="265c9" class="tk">TCD</a>[<a id="265c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="265c32" class="tk">DOFF</a>.<a id="265c37" class="tk">R</a> = 1;</td></tr>
<tr name="266" id="266">
<td><a id="l266" class='ln'>266</a></td><td>          <span class="ct">//设置minor loop步长，即每进行一次数据传输目的地址增长数，以字节为单位</span></td></tr>
<tr name="267" id="267">
<td><a id="l267" class='ln'>267</a></td><td>  <a id="267c3" class="tk">DMA_0</a>.<a id="267c9" class="tk">TCD</a>[<a id="267c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="267c32" class="tk">ATTR</a>.<a id="267c37" class="tk">B</a>.<a id="267c39" class="tk">DMOD</a> = 0;<span class="ct">//不选择目的地址取模</span></td></tr>
<tr name="268" id="268">
<td><a id="l268" class='ln'>268</a></td><td>  <a id="268c3" class="tk">DMA_0</a>.<a id="268c9" class="tk">TCD</a>[<a id="268c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="268c32" class="tk">ATTR</a>.<a id="268c37" class="tk">B</a>.<a id="268c39" class="tk">DSIZE</a> = 0;<span class="ct">//目标数据字长，0:8-bit 1:16-bit 2:32-bit</span></td></tr>
<tr name="269" id="269">
<td><a id="l269" class='ln'>269</a></td><td>  <a id="269c3" class="tk">DMA_0</a>.<a id="269c9" class="tk">TCD</a>[<a id="269c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="269c32" class="tk">DLASTSGA</a>.<a id="269c41" class="tk">R</a> = <a id="269c45" class="tk">-</a>12;</td></tr>
<tr name="270" id="270">
<td><a id="l270" class='ln'>270</a></td><td>  <span class="ct">//数据传输完后对目的地址进行调整，完成后的地址加上该寄存器的值为最终目的地址,以字节为单位</span></td></tr>
<tr name="271" id="271">
<td><a id="l271" class='ln'>271</a></td><td>  <a id="271c3" class="tk">DMA_0</a>.<a id="271c9" class="tk">TCD</a>[<a id="271c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="271c32" class="tk">NBYTES</a>.<a id="271c39" class="tk">MLNO</a>.<a id="271c44" class="tk">B</a>.<a id="271c46" class="tk">NBYTES</a> = 1;<span class="ct">//选择minor loop传输的字节数目</span></td></tr>
<tr name="272" id="272">
<td><a id="l272" class='ln'>272</a></td><td>  <a id="272c3" class="tk">DMA_0</a>.<a id="272c9" class="tk">TCD</a>[<a id="272c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="272c32" class="tk">CSR</a>.<a id="272c36" class="tk">B</a>.<a id="272c38" class="tk">DREQ</a> = 1;</td></tr>
<tr name="273" id="273">
<td><a id="l273" class='ln'>273</a></td><td>  <a id="273c3" class="tk">DMA_0</a>.<a id="273c9" class="tk">TCD</a>[<a id="273c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="273c32" class="tk">BITER</a>.<a id="273c38" class="tk">ELINKNO</a>.<a id="273c46" class="tk">B</a>.<a id="273c48" class="tk">ELINK</a> = 0;<span class="ct">//minor loop完成后不选择通道链接</span></td></tr>
<tr name="274" id="274">
<td><a id="l274" class='ln'>274</a></td><td>  <a id="274c3" class="tk">DMA_0</a>.<a id="274c9" class="tk">TCD</a>[<a id="274c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="274c32" class="tk">BITER</a>.<a id="274c38" class="tk">ELINKNO</a>.<a id="274c46" class="tk">B</a>.<a id="274c48" class="tk">BITER</a> = 12;<span class="ct">//设置开始minor loop数目</span></td></tr>
<tr name="275" id="275">
<td><a id="l275" class='ln'>275</a></td><td>  <a id="275c3" class="tk">DMA_0</a>.<a id="275c9" class="tk">TCD</a>[<a id="275c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="275c32" class="tk">CITER</a>.<a id="275c38" class="tk">ELINKNO</a>.<a id="275c46" class="tk">B</a>.<a id="275c48" class="tk">ELINK</a> = 0;<span class="ct">//minor loop完成后不选择通道链接</span></td></tr>
<tr name="276" id="276">
<td><a id="l276" class='ln'>276</a></td><td>  <a id="276c3" class="tk">DMA_0</a>.<a id="276c9" class="tk">TCD</a>[<a id="276c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="276c32" class="tk">CITER</a>.<a id="276c38" class="tk">ELINKNO</a>.<a id="276c46" class="tk">B</a>.<a id="276c48" class="tk">CITER</a> = 12;</td></tr>
<tr name="277" id="277">
<td><a id="l277" class='ln'>277</a></td><td>        <span class="ct">//设置当前minor loop数目，初始化时应保证CITER与BITER中minor loop数目相等</span></td></tr>
<tr name="278" id="278">
<td><a id="l278" class='ln'>278</a></td><td>  <a id="278c3" class="tk">DMA_0</a>.<a id="278c9" class="tk">TCD</a>[<a id="278c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="278c32" class="tk">CSR</a>.<a id="278c36" class="tk">B</a>.<a id="278c38" class="tk">INTHALF</a> = 0;</td></tr>
<tr name="279" id="279">
<td><a id="l279" class='ln'>279</a></td><td>  <a id="279c3" class="tk">DMA_0</a>.<a id="279c9" class="tk">TCD</a>[<a id="279c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="279c32" class="tk">CSR</a>.<a id="279c36" class="tk">B</a>.<a id="279c38" class="tk">INTMAJOR</a> = 0;</td></tr>
<tr name="280" id="280">
<td><a id="l280" class='ln'>280</a></td><td>  <a id="280c3" class="tk">DMA_0</a>.<a id="280c9" class="tk">TCD</a>[<a id="280c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="280c32" class="tk">CSR</a>.<a id="280c36" class="tk">B</a>.<a id="280c38" class="tk">MAJORELINK</a> = 0;</td></tr>
<tr name="281" id="281">
<td><a id="l281" class='ln'>281</a></td><td>  <a id="281c3" class="tk">DMA_0</a>.<a id="281c9" class="tk">TCD</a>[<a id="281c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="281c32" class="tk">CSR</a>.<a id="281c36" class="tk">B</a>.<a id="281c38" class="tk">ESG</a> = 0;</td></tr>
<tr name="282" id="282">
<td><a id="l282" class='ln'>282</a></td><td>  <a id="282c3" class="tk">DMA_0</a>.<a id="282c9" class="tk">TCD</a>[<a id="282c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="282c32" class="tk">CSR</a>.<a id="282c36" class="tk">B</a>.<a id="282c38" class="tk">BWC</a> = 0;</td></tr>
<tr name="283" id="283">
<td><a id="l283" class='ln'>283</a></td><td>  <a id="283c3" class="tk">DMA_0</a>.<a id="283c9" class="tk">TCD</a>[<a id="283c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="283c32" class="tk">CSR</a>.<a id="283c36" class="tk">B</a>.<a id="283c38" class="tk">DONE</a> = 0;</td></tr>
<tr name="284" id="284">
<td><a id="l284" class='ln'>284</a></td><td>  <a id="284c3" class="tk">DMA_0</a>.<a id="284c9" class="tk">TCD</a>[<a id="284c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="284c32" class="tk">CSR</a>.<a id="284c36" class="tk">B</a>.<a id="284c38" class="tk">ACTIVE</a> = 0;</td></tr>
<tr name="285" id="285">
<td><a id="l285" class='ln'>285</a></td><td>  <a id="285c3" class="tk">DMA_0</a>.<a id="285c9" class="tk">TCD</a>[<a id="285c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="285c32" class="tk">CSR</a>.<a id="285c36" class="tk">B</a>.<a id="285c38" class="tk">START</a> = 0;</td></tr>
<tr name="286" id="286">
<td><a id="l286" class='ln'>286</a></td><td>  <a id="286c3" class="tk">LINFlexD_0</a>.<a id="286c14" class="tk">DMATXE</a>.<a id="286c21" class="tk">R</a> = 0x00000001;    <span class="ct">//enable DMA (DMA_TX_CH_NUM = 1)</span></td></tr>
<tr name="287" id="287">
<td><a id="l287" class='ln'>287</a></td><td>  <a id="287c3" class="tk">DMA_0</a>.<a id="287c9" class="tk">CR</a>.<a id="287c12" class="tk">B</a>.<a id="287c14" class="tk">ERGA</a>= 1;                  <span class="ct">//选择组优先级类型为回环类型</span></td></tr>
<tr name="288" id="288">
<td><a id="l288" class='ln'>288</a></td><td>  <a id="288c3" class="tk">DMA_0</a>.<a id="288c9" class="tk">CR</a>.<a id="288c12" class="tk">B</a>.<a id="288c14" class="tk">ERCA</a>= 1;                  <span class="ct">//选择组内通道优先级类型为回环型</span></td></tr>
<tr name="289" id="289">
<td><a id="l289" class='ln'>289</a></td><td>  <a id="289c3" class="tk">DMA_0</a>.<a id="289c9" class="tk">CR</a>.<a id="289c12" class="tk">B</a>.<a id="289c14" class="tk">HALT</a>= 0;                  <span class="ct">//开始DMA传输</span></td></tr>
<tr name="290" id="290">
<td><a id="l290" class='ln'>290</a></td><td><span class="br">}</span></td></tr>
<tr name="291" id="291">
<td><a id="l291" class='ln'>291</a></td><td></td></tr>
<tr name="292" id="292">
<td><a id="l292" class='ln'>292</a></td><td><span class="ct">/*</span></td></tr>
<tr name="293" id="293">
<td><a id="l293" class='ln'>293</a></td><td><span class="ct"> * LIN-Tx DMA发送通道配置</span></td></tr>
<tr name="294" id="294">
<td><a id="l294" class='ln'>294</a></td><td><span class="ct"> */</span></td></tr>
<tr name="295" id="295">
<td><a id="l295" class='ln'>295</a></td><td><span class="kw">void</span> <a id="295c6" class="tk">ec_lin0_transmit_tcd</a>(<a id="295c27" class="tk">uint8_t</a> <a id="295c35" class="tk">Datalength</a>)</td></tr>
<tr name="296" id="296">
<td><a id="l296" class='ln'>296</a></td><td><span class="br">{</span></td></tr>
<tr name="297" id="297">
<td><a id="l297" class='ln'>297</a></td><td>  <a id="297c3" class="tk">uint8</a> <a id="297c9" class="tk">numbyte</a>;</td></tr>
<tr name="298" id="298">
<td><a id="l298" class='ln'>298</a></td><td>  <span class="kw">if</span> (<a id="298c7" class="tk">Datalength</a> <a id="298c18" class="tk">&lt;</a> 5) <span class="br">{</span></td></tr>
<tr name="299" id="299">
<td><a id="l299" class='ln'>299</a></td><td>    <a id="299c5" class="tk">numbyte</a> = 4<a id="299c16" class="tk">+</a>4;</td></tr>
<tr name="300" id="300">
<td><a id="l300" class='ln'>300</a></td><td>  <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="301" id="301">
<td><a id="l301" class='ln'>301</a></td><td>    <a id="301c5" class="tk">numbyte</a> = 4<a id="301c16" class="tk">+</a>8;</td></tr>
<tr name="302" id="302">
<td><a id="l302" class='ln'>302</a></td><td>  <span class="br">}</span></td></tr>
<tr name="303" id="303">
<td><a id="l303" class='ln'>303</a></td><td></td></tr>
<tr name="304" id="304">
<td><a id="l304" class='ln'>304</a></td><td>  <a id="304c3" class="tk">DMA_0</a>.<a id="304c9" class="tk">TCD</a>[<a id="304c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="304c32" class="tk">CITER</a>.<a id="304c38" class="tk">ELINKNO</a>.<a id="304c46" class="tk">B</a>.<a id="304c48" class="tk">CITER</a> = <a id="304c56" class="tk">numbyte</a>;</td></tr>
<tr name="305" id="305">
<td><a id="l305" class='ln'>305</a></td><td>        <span class="ct">//设置当前minor loop数目，初始化时应保证CITER与BITER中minor loop数目相等</span></td></tr>
<tr name="306" id="306">
<td><a id="l306" class='ln'>306</a></td><td>  <a id="306c3" class="tk">DMA_0</a>.<a id="306c9" class="tk">TCD</a>[<a id="306c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="306c32" class="tk">BITER</a>.<a id="306c38" class="tk">ELINKNO</a>.<a id="306c46" class="tk">B</a>.<a id="306c48" class="tk">BITER</a> = <a id="306c56" class="tk">numbyte</a>;<span class="ct">//设置开始minor loop数目</span></td></tr>
<tr name="307" id="307">
<td><a id="l307" class='ln'>307</a></td><td>  <a id="307c3" class="tk">DMA_0</a>.<a id="307c9" class="tk">TCD</a>[<a id="307c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="307c32" class="tk">NBYTES</a>.<a id="307c39" class="tk">MLNO</a>.<a id="307c44" class="tk">B</a>.<a id="307c46" class="tk">NBYTES</a> = 1;<span class="ct">//选择minor loop传输的字节数目</span></td></tr>
<tr name="308" id="308">
<td><a id="l308" class='ln'>308</a></td><td>  <a id="308c3" class="tk">DMA_0</a>.<a id="308c9" class="tk">TCD</a>[<a id="308c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="308c32" class="tk">SLAST</a>.<a id="308c38" class="tk">R</a> = <a id="308c42" class="tk">-</a><a id="308c43" class="tk">numbyte</a>;</td></tr>
<tr name="309" id="309">
<td><a id="l309" class='ln'>309</a></td><td>        <span class="ct">//数据传输完后对源地址进行调整，完成后的地址加上该寄存器的值为最终源地址</span></td></tr>
<tr name="310" id="310">
<td><a id="l310" class='ln'>310</a></td><td>  <a id="310c3" class="tk">DMA_0</a>.<a id="310c9" class="tk">TCD</a>[<a id="310c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="310c32" class="tk">DLASTSGA</a>.<a id="310c41" class="tk">R</a> = <a id="310c45" class="tk">-</a><a id="310c46" class="tk">numbyte</a>;</td></tr>
<tr name="311" id="311">
<td><a id="l311" class='ln'>311</a></td><td>  <span class="ct">//数据传输完后对目的地址进行调整，完成后的地址加上该寄存器的值为最终目的地址,以字节为单位</span></td></tr>
<tr name="312" id="312">
<td><a id="l312" class='ln'>312</a></td><td>  <a id="312c3" class="tk">DMA_0</a>.<a id="312c9" class="tk">TCD</a>[<a id="312c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="312c32" class="tk">CSR</a>.<a id="312c36" class="tk">B</a>.<a id="312c38" class="tk">DREQ</a> = 1;</td></tr>
<tr name="313" id="313">
<td><a id="l313" class='ln'>313</a></td><td>  <a id="313c3" class="tk">DMA_0</a>.<a id="313c9" class="tk">TCD</a>[<a id="313c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="313c32" class="tk">CSR</a>.<a id="313c36" class="tk">B</a>.<a id="313c38" class="tk">DONE</a> = 0;</td></tr>
<tr name="314" id="314">
<td><a id="l314" class='ln'>314</a></td><td>  <a id="314c3" class="tk">DMA_0</a>.<a id="314c9" class="tk">TCD</a>[<a id="314c13" class="tk">LIN0_COMBTX_DMACH</a>].<a id="314c32" class="tk">CSR</a>.<a id="314c36" class="tk">B</a>.<a id="314c38" class="tk">ACTIVE</a> = 0;</td></tr>
<tr name="315" id="315">
<td><a id="l315" class='ln'>315</a></td><td>  <a id="315c3" class="tk">DMA_0</a>.<a id="315c9" class="tk">SERQ</a>.<a id="315c14" class="tk">B</a>.<a id="315c16" class="tk">SERQ</a> = <a id="315c23" class="tk">LIN0_COMBTX_DMACH</a>;</td></tr>
<tr name="316" id="316">
<td><a id="l316" class='ln'>316</a></td><td>  <a id="316c3" class="tk">DMA_0</a>.<a id="316c9" class="tk">SERQ</a>.<a id="316c14" class="tk">B</a>.<a id="316c16" class="tk">NOP</a> = 0;</td></tr>
<tr name="317" id="317">
<td><a id="l317" class='ln'>317</a></td><td><span class="br">}</span></td></tr>
<tr name="318" id="318">
<td><a id="l318" class='ln'>318</a></td><td></td></tr>
<tr name="319" id="319">
<td><a id="l319" class='ln'>319</a></td><td><span class="ct">/*</span></td></tr>
<tr name="320" id="320">
<td><a id="l320" class='ln'>320</a></td><td><span class="ct"> * LIN-Tx DMA 应用层接口</span></td></tr>
<tr name="321" id="321">
<td><a id="l321" class='ln'>321</a></td><td><span class="ct"> */</span></td></tr>
<tr name="322" id="322">
<td><a id="l322" class='ln'>322</a></td><td><span class="kw">static</span> <span class="kw">inline</span> <span class="kw">void</span> <a id="322c20" class="tk">LIN0_TXMSG_SRCIDX_INC</a>(<span class="kw">void</span>)</td></tr>
<tr name="323" id="323">
<td><a id="l323" class='ln'>323</a></td><td><span class="br">{</span></td></tr>
<tr name="324" id="324">
<td><a id="l324" class='ln'>324</a></td><td>  <a id="324c3" class="tk">LIN0_TXMSG_SRCIDX</a><a id="324c20" class="tk">++</a>;</td></tr>
<tr name="325" id="325">
<td><a id="l325" class='ln'>325</a></td><td>  <span class="kw">if</span> (<a id="325c7" class="tk">LIN0_TXMSG_SRCIDX</a><a id="325c24" class="tk">&gt;=</a><a id="325c26" class="tk">LIN0_TXMSG_SIZE</a>) <span class="br">{</span></td></tr>
<tr name="326" id="326">
<td><a id="l326" class='ln'>326</a></td><td>    <a id="326c5" class="tk">LIN0_TXMSG_SRCIDX</a> = 0;</td></tr>
<tr name="327" id="327">
<td><a id="l327" class='ln'>327</a></td><td>  <span class="br">}</span></td></tr>
<tr name="328" id="328">
<td><a id="l328" class='ln'>328</a></td><td><span class="br">}</span></td></tr>
<tr name="329" id="329">
<td><a id="l329" class='ln'>329</a></td><td></td></tr>
<tr name="330" id="330">
<td><a id="l330" class='ln'>330</a></td><td><span class="kw">static</span> <span class="kw">inline</span> <span class="kw">void</span> <a id="330c20" class="tk">LIN0_TXMSG_DSTIDX_INC</a>(<span class="kw">void</span>)</td></tr>
<tr name="331" id="331">
<td><a id="l331" class='ln'>331</a></td><td><span class="br">{</span></td></tr>
<tr name="332" id="332">
<td><a id="l332" class='ln'>332</a></td><td>  <a id="332c3" class="tk">LIN0_TXMSG_DSTIDX</a><a id="332c20" class="tk">++</a>;</td></tr>
<tr name="333" id="333">
<td><a id="l333" class='ln'>333</a></td><td>  <span class="kw">if</span> (<a id="333c7" class="tk">LIN0_TXMSG_DSTIDX</a><a id="333c24" class="tk">&gt;=</a><a id="333c26" class="tk">LIN0_TXMSG_SIZE</a>) <span class="br">{</span></td></tr>
<tr name="334" id="334">
<td><a id="l334" class='ln'>334</a></td><td>    <a id="334c5" class="tk">LIN0_TXMSG_DSTIDX</a> = 0;</td></tr>
<tr name="335" id="335">
<td><a id="l335" class='ln'>335</a></td><td>  <span class="br">}</span></td></tr>
<tr name="336" id="336">
<td><a id="l336" class='ln'>336</a></td><td><span class="br">}</span></td></tr>
<tr name="337" id="337">
<td><a id="l337" class='ln'>337</a></td><td></td></tr>
<tr name="338" id="338">
<td><a id="l338" class='ln'>338</a></td><td><span class="kw">void</span> <a id="338c6" class="tk">Lin0_PushTxMsg</a>(<a id="338c21" class="tk">uint8</a> <a id="338c27" class="tk">Tx_ID</a>, <a id="338c34" class="tk">uint8</a> <a id="338c40" class="tk">Datalength</a>, <a id="338c52" class="tk">uint8</a> <a id="338c58" class="tk">Tx_Data</a>[], <a id="338c69" class="tk">boolean</a></td></tr>
<tr name="339" id="339">
<td><a id="l339" class='ln'>339</a></td><td>                    <a id="339c21" class="tk">Checksum_Type</a>)</td></tr>
<tr name="340" id="340">
<td><a id="l340" class='ln'>340</a></td><td><span class="br">{</span></td></tr>
<tr name="341" id="341">
<td><a id="l341" class='ln'>341</a></td><td>  <a id="341c3" class="tk">uint8_t</a> <a id="341c11" class="tk">i</a> = 0;</td></tr>
<tr name="342" id="342">
<td><a id="l342" class='ln'>342</a></td><td>  <a id="342c3" class="tk">pLIN_TXMSG_T</a> <a id="342c16" class="tk">pTxMsg</a> = <a id="342c25" class="tk">&amp;</a><a id="342c26" class="tk">LIN0_TXMSG_BUF</a>[<a id="342c41" class="tk">LIN0_TXMSG_DSTIDX</a>];</td></tr>
<tr name="343" id="343">
<td><a id="l343" class='ln'>343</a></td><td>  <a id="343c3" class="tk">pTxMsg</a>-&gt;<a id="343c11" class="tk">BufId</a> = <a id="343c19" class="tk">Tx_ID</a>;</td></tr>
<tr name="344" id="344">
<td><a id="l344" class='ln'>344</a></td><td>  <a id="344c3" class="tk">pTxMsg</a>-&gt;<a id="344c11" class="tk">Length</a> = <a id="344c20" class="tk">Datalength</a>;</td></tr>
<tr name="345" id="345">
<td><a id="l345" class='ln'>345</a></td><td>  <a id="345c3" class="tk">pTxMsg</a>-&gt;<a id="345c11" class="tk">ChecksumType</a> = <a id="345c26" class="tk">Checksum_Type</a>;</td></tr>
<tr name="346" id="346">
<td><a id="l346" class='ln'>346</a></td><td>  <span class="kw">for</span> (<a id="346c8" class="tk">i</a>=0; <a id="346c13" class="tk">i</a><a id="346c14" class="tk">&lt;</a><a id="346c15" class="tk">Datalength</a>; <a id="346c27" class="tk">i</a><a id="346c28" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="347" id="347">
<td><a id="l347" class='ln'>347</a></td><td>    <a id="347c5" class="tk">pTxMsg</a>-&gt;<a id="347c13" class="tk">Data</a>[<a id="347c18" class="tk">i</a>] = <a id="347c23" class="tk">Tx_Data</a>[<a id="347c31" class="tk">i</a>];</td></tr>
<tr name="348" id="348">
<td><a id="l348" class='ln'>348</a></td><td>  <span class="br">}</span></td></tr>
<tr name="349" id="349">
<td><a id="l349" class='ln'>349</a></td><td></td></tr>
<tr name="350" id="350">
<td><a id="l350" class='ln'>350</a></td><td>  <a id="350c3" class="tk">LIN0_TXMSG_DSTIDX_INC</a>();</td></tr>
<tr name="351" id="351">
<td><a id="l351" class='ln'>351</a></td><td><span class="br">}</span></td></tr>
<tr name="352" id="352">
<td><a id="l352" class='ln'>352</a></td><td></td></tr>
<tr name="353" id="353">
<td><a id="l353" class='ln'>353</a></td><td><span class="ct">/*</span></td></tr>
<tr name="354" id="354">
<td><a id="l354" class='ln'>354</a></td><td><span class="ct"> * LIN-Tx DMA 底层发送</span></td></tr>
<tr name="355" id="355">
<td><a id="l355" class='ln'>355</a></td><td><span class="ct"> */</span></td></tr>
<tr name="356" id="356">
<td><a id="l356" class='ln'>356</a></td><td><span class="kw">static</span> <a id="356c8" class="tk">uint8_t</a> <a id="356c16" class="tk">is_lin0_txlock</a>(<span class="kw">void</span>)</td></tr>
<tr name="357" id="357">
<td><a id="l357" class='ln'>357</a></td><td><span class="br">{</span></td></tr>
<tr name="358" id="358">
<td><a id="l358" class='ln'>358</a></td><td>  <span class="kw">if</span> (1<a id="358c8" class="tk">==</a><a id="358c10" class="tk">DMA_0</a>.<a id="358c16" class="tk">TCD</a>[<a id="358c20" class="tk">LIN0_COMBTX_DMACH</a>].<a id="358c39" class="tk">CSR</a>.<a id="358c43" class="tk">B</a>.<a id="358c45" class="tk">DONE</a>) <span class="br">{</span></td></tr>
<tr name="359" id="359">
<td><a id="l359" class='ln'>359</a></td><td>    <a id="359c5" class="tk">ec_lin0_txlock</a> = 0;</td></tr>
<tr name="360" id="360">
<td><a id="l360" class='ln'>360</a></td><td>  <span class="br">}</span></td></tr>
<tr name="361" id="361">
<td><a id="l361" class='ln'>361</a></td><td></td></tr>
<tr name="362" id="362">
<td><a id="l362" class='ln'>362</a></td><td>  <span class="kw">return</span> <a id="362c10" class="tk">ec_lin0_txlock</a>;</td></tr>
<tr name="363" id="363">
<td><a id="l363" class='ln'>363</a></td><td><span class="br">}</span></td></tr>
<tr name="364" id="364">
<td><a id="l364" class='ln'>364</a></td><td></td></tr>
<tr name="365" id="365">
<td><a id="l365" class='ln'>365</a></td><td><a id="365c1" class="tk">uint8_t</a> <a id="365c9" class="tk">is_lin0_txbusy</a>(<span class="kw">void</span>)</td></tr>
<tr name="366" id="366">
<td><a id="l366" class='ln'>366</a></td><td><span class="br">{</span></td></tr>
<tr name="367" id="367">
<td><a id="l367" class='ln'>367</a></td><td>  <span class="kw">if</span> (2<a id="367c8" class="tk">==</a><a id="367c10" class="tk">LINFlexD_0</a>.<a id="367c21" class="tk">LINSR</a>.<a id="367c27" class="tk">B</a>.<a id="367c29" class="tk">LINS</a> <a id="367c34" class="tk">&amp;&amp;</a> 0<a id="367c38" class="tk">==</a><a id="367c40" class="tk">is_lin0_txlock</a>()) <span class="br">{</span></td></tr>
<tr name="368" id="368">
<td><a id="l368" class='ln'>368</a></td><td>    <span class="kw">return</span> 0;</td></tr>
<tr name="369" id="369">
<td><a id="l369" class='ln'>369</a></td><td>  <span class="br">}</span></td></tr>
<tr name="370" id="370">
<td><a id="l370" class='ln'>370</a></td><td></td></tr>
<tr name="371" id="371">
<td><a id="l371" class='ln'>371</a></td><td>  <span class="kw">return</span> 1;</td></tr>
<tr name="372" id="372">
<td><a id="l372" class='ln'>372</a></td><td><span class="br">}</span></td></tr>
<tr name="373" id="373">
<td><a id="l373" class='ln'>373</a></td><td></td></tr>
<tr name="374" id="374">
<td><a id="l374" class='ln'>374</a></td><td><span class="kw">void</span> <a id="374c6" class="tk">ec_lin0_transmit_dma</a>(<a id="374c27" class="tk">uint8</a> <a id="374c33" class="tk">Tx_ID</a>, <a id="374c40" class="tk">uint8</a> <a id="374c46" class="tk">Datalength</a>, <a id="374c58" class="tk">uint8</a> <a id="374c64" class="tk">Tx_Data</a>[],</td></tr>
<tr name="375" id="375">
<td><a id="l375" class='ln'>375</a></td><td>  <a id="375c3" class="tk">boolean</a> <a id="375c11" class="tk">Checksum_Type</a>)</td></tr>
<tr name="376" id="376">
<td><a id="l376" class='ln'>376</a></td><td><span class="br">{</span></td></tr>
<tr name="377" id="377">
<td><a id="l377" class='ln'>377</a></td><td>  <a id="377c3" class="tk">uint8_t</a> <a id="377c11" class="tk">i</a>;</td></tr>
<tr name="378" id="378">
<td><a id="l378" class='ln'>378</a></td><td>  <span class="kw">if</span> (0 <a id="378c9" class="tk">==</a> <a id="378c12" class="tk">is_lin0_txlock</a>()) <span class="br">{</span></td></tr>
<tr name="379" id="379">
<td><a id="l379" class='ln'>379</a></td><td>    <a id="379c5" class="tk">ec_lin0_txlock</a> = 1;</td></tr>
<tr name="380" id="380">
<td><a id="l380" class='ln'>380</a></td><td>    <a id="380c5" class="tk">ec_lin_dma_info</a>.<a id="380c21" class="tk">BIDR</a>.<a id="380c26" class="tk">B</a>.<a id="380c28" class="tk">DFL</a> = <a id="380c34" class="tk">Datalength</a> <a id="380c45" class="tk">-</a> 1;<span class="ct">/* DFL = Number of data bytes - 1 */</span></td></tr>
<tr name="381" id="381">
<td><a id="l381" class='ln'>381</a></td><td>    <a id="381c5" class="tk">ec_lin_dma_info</a>.<a id="381c21" class="tk">BIDR</a>.<a id="381c26" class="tk">B</a>.<a id="381c28" class="tk">DIR</a> = 1;</td></tr>
<tr name="382" id="382">
<td><a id="l382" class='ln'>382</a></td><td>                        <span class="ct">/* LINFlexD transmits the data from the BDR registers */</span></td></tr>
<tr name="383" id="383">
<td><a id="l383" class='ln'>383</a></td><td>    <a id="383c5" class="tk">ec_lin_dma_info</a>.<a id="383c21" class="tk">BIDR</a>.<a id="383c26" class="tk">B</a>.<a id="383c28" class="tk">CCS</a> = <a id="383c34" class="tk">Checksum_Type</a>;</td></tr>
<tr name="384" id="384">
<td><a id="l384" class='ln'>384</a></td><td>                                <span class="ct">/* 0: Enhanced Checksum ; 1: Classic Checksum */</span></td></tr>
<tr name="385" id="385">
<td><a id="l385" class='ln'>385</a></td><td>    <a id="385c5" class="tk">ec_lin_dma_info</a>.<a id="385c21" class="tk">BIDR</a>.<a id="385c26" class="tk">B</a>.<a id="385c28" class="tk">ID</a> = <a id="385c33" class="tk">Tx_ID</a>;</td></tr>
<tr name="386" id="386">
<td><a id="l386" class='ln'>386</a></td><td>    <a id="386c5" class="tk">ec_lin_dma_info</a>.<a id="386c21" class="tk">BDRL</a>.<a id="386c26" class="tk">R</a> = 0;</td></tr>
<tr name="387" id="387">
<td><a id="l387" class='ln'>387</a></td><td>    <a id="387c5" class="tk">ec_lin_dma_info</a>.<a id="387c21" class="tk">BDRM</a>.<a id="387c26" class="tk">R</a> = 0;</td></tr>
<tr name="388" id="388">
<td><a id="l388" class='ln'>388</a></td><td>    <span class="kw">if</span> (<a id="388c9" class="tk">Datalength</a> <a id="388c20" class="tk">&lt;</a> 5) <span class="br">{</span></td></tr>
<tr name="389" id="389">
<td><a id="l389" class='ln'>389</a></td><td>      <span class="kw">for</span> (<a id="389c12" class="tk">i</a>=0; <a id="389c17" class="tk">i</a><a id="389c18" class="tk">&lt;</a><a id="389c19" class="tk">Datalength</a>; <a id="389c31" class="tk">i</a><a id="389c32" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="390" id="390">
<td><a id="l390" class='ln'>390</a></td><td>        <a id="390c9" class="tk">ec_lin_dma_info</a>.<a id="390c25" class="tk">BDRL</a>.<a id="390c30" class="tk">R</a> <a id="390c32" class="tk">+=</a> ((<a id="390c37" class="tk">uint32</a>)<a id="390c44" class="tk">Tx_Data</a>[<a id="390c52" class="tk">i</a>] <a id="390c55" class="tk">&lt;&lt;</a> <a id="390c58" class="tk">i</a><a id="390c59" class="tk">*</a>8);</td></tr>
<tr name="391" id="391">
<td><a id="l391" class='ln'>391</a></td><td>      <span class="br">}</span></td></tr>
<tr name="392" id="392">
<td><a id="l392" class='ln'>392</a></td><td>    <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="393" id="393">
<td><a id="l393" class='ln'>393</a></td><td>      <span class="kw">for</span> (<a id="393c12" class="tk">i</a>=0; <a id="393c17" class="tk">i</a><a id="393c18" class="tk">&lt;</a><a id="393c19" class="tk">Datalength</a>; <a id="393c31" class="tk">i</a><a id="393c32" class="tk">++</a>) <span class="br">{</span></td></tr>
<tr name="394" id="394">
<td><a id="l394" class='ln'>394</a></td><td>        <span class="kw">if</span> (<a id="394c13" class="tk">i</a><a id="394c14" class="tk">&lt;</a>4) <span class="br">{</span></td></tr>
<tr name="395" id="395">
<td><a id="l395" class='ln'>395</a></td><td>          <a id="395c11" class="tk">ec_lin_dma_info</a>.<a id="395c27" class="tk">BDRL</a>.<a id="395c32" class="tk">R</a> <a id="395c34" class="tk">+=</a> ((<a id="395c39" class="tk">uint32</a>)<a id="395c46" class="tk">Tx_Data</a>[<a id="395c54" class="tk">i</a>] <a id="395c57" class="tk">&lt;&lt;</a> <a id="395c60" class="tk">i</a><a id="395c61" class="tk">*</a>8);</td></tr>
<tr name="396" id="396">
<td><a id="l396" class='ln'>396</a></td><td>        <span class="br">}</span> <span class="kw">else</span> <span class="br">{</span></td></tr>
<tr name="397" id="397">
<td><a id="l397" class='ln'>397</a></td><td>          <a id="397c11" class="tk">ec_lin_dma_info</a>.<a id="397c27" class="tk">BDRM</a>.<a id="397c32" class="tk">R</a> <a id="397c34" class="tk">+=</a> ((<a id="397c39" class="tk">uint32</a>)<a id="397c46" class="tk">Tx_Data</a>[<a id="397c54" class="tk">i</a>] <a id="397c57" class="tk">&lt;&lt;</a> (<a id="397c61" class="tk">i</a><a id="397c62" class="tk">-</a>4)<a id="397c65" class="tk">*</a>8);</td></tr>
<tr name="398" id="398">
<td><a id="l398" class='ln'>398</a></td><td>        <span class="br">}</span></td></tr>
<tr name="399" id="399">
<td><a id="l399" class='ln'>399</a></td><td>      <span class="br">}</span></td></tr>
<tr name="400" id="400">
<td><a id="l400" class='ln'>400</a></td><td>    <span class="br">}</span></td></tr>
<tr name="401" id="401">
<td><a id="l401" class='ln'>401</a></td><td></td></tr>
<tr name="402" id="402">
<td><a id="l402" class='ln'>402</a></td><td>    <a id="402c5" class="tk">ec_lin0_transmit_tcd</a>(<a id="402c26" class="tk">Datalength</a>);</td></tr>
<tr name="403" id="403">
<td><a id="l403" class='ln'>403</a></td><td>  <span class="br">}</span></td></tr>
<tr name="404" id="404">
<td><a id="l404" class='ln'>404</a></td><td><span class="br">}</span></td></tr>
<tr name="405" id="405">
<td><a id="l405" class='ln'>405</a></td><td></td></tr>
<tr name="406" id="406">
<td><a id="l406" class='ln'>406</a></td><td><span class="kw">void</span> <a id="406c6" class="tk">Lin0_TxBackground</a>(<span class="kw">void</span>)</td></tr>
<tr name="407" id="407">
<td><a id="l407" class='ln'>407</a></td><td><span class="br">{</span></td></tr>
<tr name="408" id="408">
<td><a id="l408" class='ln'>408</a></td><td>  <span class="ct">// LIN0</span></td></tr>
<tr name="409" id="409">
<td><a id="l409" class='ln'>409</a></td><td>  <span class="kw">if</span> (0<a id="409c8" class="tk">==</a><a id="409c10" class="tk">is_lin0_txbusy</a>()<a id="409c26" class="tk">&amp;&amp;</a>0<a id="409c29" class="tk">==</a><a id="409c31" class="tk">LIN0_RXMSG_ACTIVE</a>) <span class="br">{</span></td></tr>
<tr name="410" id="410">
<td><a id="l410" class='ln'>410</a></td><td>    <span class="kw">if</span> (<a id="410c9" class="tk">LIN0_TXMSG_SRCIDX</a> <a id="410c27" class="tk">!=</a> <a id="410c30" class="tk">LIN0_TXMSG_DSTIDX</a>) <span class="br">{</span></td></tr>
<tr name="411" id="411">
<td><a id="l411" class='ln'>411</a></td><td>      <a id="411c7" class="tk">pLIN_TXMSG_T</a> <a id="411c20" class="tk">pTxMsg</a> = <a id="411c29" class="tk">&amp;</a><a id="411c30" class="tk">LIN0_TXMSG_BUF</a>[<a id="411c45" class="tk">LIN0_TXMSG_SRCIDX</a>];</td></tr>
<tr name="412" id="412">
<td><a id="l412" class='ln'>412</a></td><td>      <a id="412c7" class="tk">ec_lin0_transmit_dma</a>(<a id="412c28" class="tk">pTxMsg</a>-&gt;<a id="412c36" class="tk">BufId</a>, <a id="412c43" class="tk">pTxMsg</a>-&gt;<a id="412c51" class="tk">Length</a>, <a id="412c59" class="tk">pTxMsg</a>-&gt;<a id="412c67" class="tk">Data</a>,</td></tr>
<tr name="413" id="413">
<td><a id="l413" class='ln'>413</a></td><td>                           <a id="413c28" class="tk">pTxMsg</a>-&gt;<a id="413c36" class="tk">ChecksumType</a>);</td></tr>
<tr name="414" id="414">
<td><a id="l414" class='ln'>414</a></td><td>      <a id="414c7" class="tk">LIN0_TXMSG_SRCIDX_INC</a>();</td></tr>
<tr name="415" id="415">
<td><a id="l415" class='ln'>415</a></td><td>    <span class="br">}</span></td></tr>
<tr name="416" id="416">
<td><a id="l416" class='ln'>416</a></td><td>  <span class="br">}</span></td></tr>
<tr name="417" id="417">
<td><a id="l417" class='ln'>417</a></td><td><span class="br">}</span></td></tr>
<tr name="418" id="418">
<td><a id="l418" class='ln'>418</a></td><td></td></tr>
<tr name="419" id="419">
<td><a id="l419" class='ln'>419</a></td><td><span class="kw">void</span> <a id="419c6" class="tk">Lin0_Background</a>(<span class="kw">void</span>)</td></tr>
<tr name="420" id="420">
<td><a id="l420" class='ln'>420</a></td><td><span class="br">{</span></td></tr>
<tr name="421" id="421">
<td><a id="l421" class='ln'>421</a></td><td>  <a id="421c3" class="tk">Lin0_TxBackground</a>();</td></tr>
<tr name="422" id="422">
<td><a id="l422" class='ln'>422</a></td><td></td></tr>
<tr name="423" id="423">
<td><a id="l423" class='ln'>423</a></td><td>  <span class="ct">//LinNm_RxBackground();</span></td></tr>
<tr name="424" id="424">
<td><a id="l424" class='ln'>424</a></td><td><span class="br">}</span></td></tr>
<tr name="425" id="425">
<td><a id="l425" class='ln'>425</a></td><td></td></tr>
<tr name="426" id="426">
<td><a id="l426" class='ln'>426</a></td><td><span class="pp">#if</span> 0</td></tr>
<tr name="427" id="427">
<td><a id="l427" class='ln'>427</a></td><td></td></tr>
<tr name="428" id="428">
<td><a id="l428" class='ln'>428</a></td><td><span class="kw">void</span> <a id="428c6" class="tk">ec_scia_init_rxdma</a>()</td></tr>
<tr name="429" id="429">
<td><a id="l429" class='ln'>429</a></td><td><span class="br">{</span></td></tr>
<tr name="430" id="430">
<td><a id="l430" class='ln'>430</a></td><td>  <span class="ct">//EDMA.TCD[ESCIA_COMBRX_DMACH].SADDR = (vuint32_t) &amp;ec_scia_rxdata;  /* Load address of source data */</span></td></tr>
<tr name="431" id="431">
<td><a id="l431" class='ln'>431</a></td><td>  <a id="431c3" class="tk">EDMA</a>.<a id="431c8" class="tk">TCD</a>[<a id="431c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="431c32" class="tk">SADDR</a> = (<a id="431c41" class="tk">vuint32_t</a>) <a id="431c52" class="tk">&amp;</a>(<a id="431c54" class="tk">ESCI</a>(0).<a id="431c62" class="tk">DR</a>.<a id="431c65" class="tk">R</a>)<a id="431c67" class="tk">+</a>1;<span class="ct">/* Load address of source data */</span></td></tr>
<tr name="432" id="432">
<td><a id="l432" class='ln'>432</a></td><td>  <a id="432c3" class="tk">EDMA</a>.<a id="432c8" class="tk">TCD</a>[<a id="432c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="432c32" class="tk">SSIZE</a> = 0;</td></tr>
<tr name="433" id="433">
<td><a id="l433" class='ln'>433</a></td><td>  <a id="433c3" class="tk">EDMA</a>.<a id="433c8" class="tk">TCD</a>[<a id="433c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="433c32" class="tk">SOFF</a> = 0;</td></tr>
<tr name="434" id="434">
<td><a id="l434" class='ln'>434</a></td><td>  <a id="434c3" class="tk">EDMA</a>.<a id="434c8" class="tk">TCD</a>[<a id="434c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="434c32" class="tk">SLAST</a> = 0;</td></tr>
<tr name="435" id="435">
<td><a id="l435" class='ln'>435</a></td><td>  <a id="435c3" class="tk">EDMA</a>.<a id="435c8" class="tk">TCD</a>[<a id="435c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="435c32" class="tk">SMOD</a> = 0;</td></tr>
<tr name="436" id="436">
<td><a id="l436" class='ln'>436</a></td><td>  <a id="436c3" class="tk">EDMA</a>.<a id="436c8" class="tk">TCD</a>[<a id="436c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="436c32" class="tk">DADDR</a> = (<a id="436c41" class="tk">vuint32_t</a>) <a id="436c52" class="tk">&amp;</a><a id="436c53" class="tk">ec_scia_rxdata</a>;<span class="ct">/* Load address of destination */</span></td></tr>
<tr name="437" id="437">
<td><a id="l437" class='ln'>437</a></td><td></td></tr>
<tr name="438" id="438">
<td><a id="l438" class='ln'>438</a></td><td>  <span class="ct">//EDMA.TCD[ESCIA_COMBRX_DMACH].DADDR = (vuint32_t) &amp;ec_scia_dstdata; /* Load address of destination */</span></td></tr>
<tr name="439" id="439">
<td><a id="l439" class='ln'>439</a></td><td>  <a id="439c3" class="tk">EDMA</a>.<a id="439c8" class="tk">TCD</a>[<a id="439c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="439c32" class="tk">DSIZE</a> = 0;</td></tr>
<tr name="440" id="440">
<td><a id="l440" class='ln'>440</a></td><td>  <a id="440c3" class="tk">EDMA</a>.<a id="440c8" class="tk">TCD</a>[<a id="440c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="440c32" class="tk">DOFF</a> = 1;</td></tr>
<tr name="441" id="441">
<td><a id="l441" class='ln'>441</a></td><td>  <a id="441c3" class="tk">EDMA</a>.<a id="441c8" class="tk">TCD</a>[<a id="441c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="441c32" class="tk">DLAST_SGA</a> = 0;</td></tr>
<tr name="442" id="442">
<td><a id="l442" class='ln'>442</a></td><td>  <a id="442c3" class="tk">EDMA</a>.<a id="442c8" class="tk">TCD</a>[<a id="442c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="442c32" class="tk">DMOD</a> = 0;</td></tr>
<tr name="443" id="443">
<td><a id="l443" class='ln'>443</a></td><td>  <a id="443c3" class="tk">EDMA</a>.<a id="443c8" class="tk">TCD</a>[<a id="443c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="443c32" class="tk">NBYTES</a> = 1;<span class="ct">/* Transfer 1 byte per minor loop */</span></td></tr>
<tr name="444" id="444">
<td><a id="l444" class='ln'>444</a></td><td>  <a id="444c3" class="tk">EDMA</a>.<a id="444c8" class="tk">TCD</a>[<a id="444c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="444c32" class="tk">BITER</a> = 12;</td></tr>
<tr name="445" id="445">
<td><a id="l445" class='ln'>445</a></td><td>  <a id="445c3" class="tk">EDMA</a>.<a id="445c8" class="tk">TCD</a>[<a id="445c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="445c32" class="tk">CITER</a> = 12;<span class="ct">/* Initialize current iteraction count */</span></td></tr>
<tr name="446" id="446">
<td><a id="l446" class='ln'>446</a></td><td>  <a id="446c3" class="tk">EDMA</a>.<a id="446c8" class="tk">TCD</a>[<a id="446c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="446c32" class="tk">D_REQ</a> = 1;</td></tr>
<tr name="447" id="447">
<td><a id="l447" class='ln'>447</a></td><td>                                    <span class="ct">/* Disable channel when major loop is done*/</span></td></tr>
<tr name="448" id="448">
<td><a id="l448" class='ln'>448</a></td><td>  <a id="448c3" class="tk">EDMA</a>.<a id="448c8" class="tk">TCD</a>[<a id="448c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="448c32" class="tk">INT_HALF</a> = 0;</td></tr>
<tr name="449" id="449">
<td><a id="l449" class='ln'>449</a></td><td>  <a id="449c3" class="tk">EDMA</a>.<a id="449c8" class="tk">TCD</a>[<a id="449c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="449c32" class="tk">INT_MAJ</a> = 0;</td></tr>
<tr name="450" id="450">
<td><a id="l450" class='ln'>450</a></td><td>  <a id="450c3" class="tk">EDMA</a>.<a id="450c8" class="tk">TCD</a>[<a id="450c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="450c32" class="tk">CITERE_LINK</a> = 0;<span class="ct">/* Linking is not used */</span></td></tr>
<tr name="451" id="451">
<td><a id="l451" class='ln'>451</a></td><td>  <a id="451c3" class="tk">EDMA</a>.<a id="451c8" class="tk">TCD</a>[<a id="451c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="451c32" class="tk">BITERE_LINK</a> = 0;</td></tr>
<tr name="452" id="452">
<td><a id="l452" class='ln'>452</a></td><td>  <a id="452c3" class="tk">EDMA</a>.<a id="452c8" class="tk">TCD</a>[<a id="452c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="452c32" class="tk">MAJORE_LINK</a> = 0;</td></tr>
<tr name="453" id="453">
<td><a id="l453" class='ln'>453</a></td><td>  <a id="453c3" class="tk">EDMA</a>.<a id="453c8" class="tk">TCD</a>[<a id="453c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="453c32" class="tk">E_SG</a> = 0;</td></tr>
<tr name="454" id="454">
<td><a id="l454" class='ln'>454</a></td><td>  <a id="454c3" class="tk">EDMA</a>.<a id="454c8" class="tk">TCD</a>[<a id="454c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="454c32" class="tk">BWC</a> = 0;</td></tr>
<tr name="455" id="455">
<td><a id="l455" class='ln'>455</a></td><td>                                      <span class="ct">/* Default bandwidth control- no stalls */</span></td></tr>
<tr name="456" id="456">
<td><a id="l456" class='ln'>456</a></td><td>  <a id="456c3" class="tk">EDMA</a>.<a id="456c8" class="tk">TCD</a>[<a id="456c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="456c32" class="tk">START</a> = 0;<span class="ct">/* Initialize status flags */</span></td></tr>
<tr name="457" id="457">
<td><a id="l457" class='ln'>457</a></td><td>  <a id="457c3" class="tk">EDMA</a>.<a id="457c8" class="tk">TCD</a>[<a id="457c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="457c32" class="tk">DONE</a> = 0;</td></tr>
<tr name="458" id="458">
<td><a id="l458" class='ln'>458</a></td><td>  <a id="458c3" class="tk">EDMA</a>.<a id="458c8" class="tk">TCD</a>[<a id="458c12" class="tk">ESCIA_COMBRX_DMACH</a>].<a id="458c32" class="tk">ACTIVE</a> = 0;</td></tr>
<tr name="459" id="459">
<td><a id="l459" class='ln'>459</a></td><td>  <a id="459c3" class="tk">ESCI</a>(0).<a id="459c11" class="tk">CR2</a>.<a id="459c15" class="tk">B</a>.<a id="459c17" class="tk">RXDMA</a> = 1;</td></tr>
<tr name="460" id="460">
<td><a id="l460" class='ln'>460</a></td><td><span class="br">}</span></td></tr>
<tr name="461" id="461">
<td><a id="l461" class='ln'>461</a></td><td></td></tr>
<tr name="462" id="462">
<td><a id="l462" class='ln'>462</a></td><td><span class="pp">#endif</span></td></tr>
<tr name="463" id="463">
<td><a id="l463" class='ln'>463</a></td><td><span class="pp">#endif</span></td></tr>
<tr name="464" id="464">
<td><a id="l464" class='ln'>464</a></td><td></td></tr>
<tr name="465" id="465">
<td><a id="l465" class='ln'>465</a></td><td><span class="ct">/* File trailer for ECUCoder generated file lin.c.</span></td></tr>
<tr name="466" id="466">
<td><a id="l466" class='ln'>466</a></td><td><span class="ct"> *</span></td></tr>
<tr name="467" id="467">
<td><a id="l467" class='ln'>467</a></td><td><span class="ct"> * [EOF]</span></td></tr>
<tr name="468" id="468">
<td><a id="l468" class='ln'>468</a></td><td><span class="ct"> */</span></td></tr>
<tr name="469" id="469">
<td><a id="l469" class='ln'>469</a></td><td></td></tr>
</table>
</pre>
</body>
</html>
